mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Streamline getting other user id from invited direct chat
This commit is contained in:
parent
0b8527eb1b
commit
b9255803fb
4 changed files with 15 additions and 20 deletions
|
@ -2614,12 +2614,6 @@ Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &members
|
||||||
return QString("Empty Room");
|
return QString("Empty Room");
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomMember
|
|
||||||
Cache::getDirectInviteMember(const std::string &room_id)
|
|
||||||
{
|
|
||||||
return getMembersFromInvitedRoom(room_id, 0, 1).front();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Cache::getInviteRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
|
Cache::getInviteRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
|
||||||
{
|
{
|
||||||
|
@ -2784,9 +2778,7 @@ Cache::getMembers(const std::string &room_id, std::size_t startIndex, std::size_
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RoomMember>
|
std::vector<RoomMember>
|
||||||
Cache::getMembersFromInvitedRoom(const std::string &room_id,
|
Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex, std::size_t len)
|
||||||
std::size_t startIndex,
|
|
||||||
std::size_t len)
|
|
||||||
{
|
{
|
||||||
auto txn = ro_txn(env_);
|
auto txn = ro_txn(env_);
|
||||||
auto db = getInviteMembersDb(txn, room_id);
|
auto db = getInviteMembersDb(txn, room_id);
|
||||||
|
@ -4864,10 +4856,10 @@ getMembers(const std::string &room_id, std::size_t startIndex, std::size_t len)
|
||||||
return instance_->getMembers(room_id, startIndex, len);
|
return instance_->getMembers(room_id, startIndex, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomMember
|
std::vector<RoomMember>
|
||||||
getDirectInviteMember(const std::string &room_id)
|
getMembersFromInvite(const std::string &room_id, std::size_t startIndex, std::size_t len)
|
||||||
{
|
{
|
||||||
return instance_->getDirectInviteMember(room_id);
|
return instance_->getMembersFromInvite(room_id, startIndex, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -83,10 +83,9 @@ getRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb);
|
||||||
//! Retrieve member info from a room.
|
//! Retrieve member info from a room.
|
||||||
std::vector<RoomMember>
|
std::vector<RoomMember>
|
||||||
getMembers(const std::string &room_id, std::size_t startIndex = 0, std::size_t len = 30);
|
getMembers(const std::string &room_id, std::size_t startIndex = 0, std::size_t len = 30);
|
||||||
|
//! Retrive member info from an invite.
|
||||||
//! Get the other person from an invite to a direct chat.
|
std::vector<RoomMember>
|
||||||
RoomMember
|
getMembersFromInvite(const std::string &room_id, std::size_t start_index = 0, std::size_t len = 30);
|
||||||
getDirectInviteMember(const std::string &room_id);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isInitialized();
|
isInitialized();
|
||||||
|
|
|
@ -110,9 +110,9 @@ public:
|
||||||
std::size_t startIndex = 0,
|
std::size_t startIndex = 0,
|
||||||
std::size_t len = 30);
|
std::size_t len = 30);
|
||||||
|
|
||||||
std::vector<RoomMember> getMembersFromInvitedRoom(const std::string &room_id,
|
std::vector<RoomMember> getMembersFromInvite(const std::string &room_id,
|
||||||
std::size_t startIndex = 0,
|
std::size_t startIndex = 0,
|
||||||
std::size_t len = 30);
|
std::size_t len = 30);
|
||||||
size_t memberCount(const std::string &room_id);
|
size_t memberCount(const std::string &room_id);
|
||||||
|
|
||||||
void saveState(const mtx::responses::Sync &res);
|
void saveState(const mtx::responses::Sync &res);
|
||||||
|
|
|
@ -165,9 +165,13 @@ RoomlistModel::data(const QModelIndex &index, int role) const
|
||||||
case Roles::Tags:
|
case Roles::Tags:
|
||||||
return QStringList();
|
return QStringList();
|
||||||
case Roles::IsDirect:
|
case Roles::IsDirect:
|
||||||
|
// The list of users from the room doesn't contain the invited
|
||||||
|
// users, so we won't factor the invite into the count
|
||||||
return room.member_count == 1;
|
return room.member_count == 1;
|
||||||
case Roles::DirectChatOtherUserId:
|
case Roles::DirectChatOtherUserId:
|
||||||
return cache::getDirectInviteMember(roomid.toStdString()).user_id;
|
return cache::getMembersFromInvite(roomid.toStdString(), 0, 1)
|
||||||
|
.front()
|
||||||
|
.user_id;
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue