mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +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");
|
||||
}
|
||||
|
||||
RoomMember
|
||||
Cache::getDirectInviteMember(const std::string &room_id)
|
||||
{
|
||||
return getMembersFromInvitedRoom(room_id, 0, 1).front();
|
||||
}
|
||||
|
||||
QString
|
||||
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>
|
||||
Cache::getMembersFromInvitedRoom(const std::string &room_id,
|
||||
std::size_t startIndex,
|
||||
std::size_t len)
|
||||
Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex, std::size_t len)
|
||||
{
|
||||
auto txn = ro_txn(env_);
|
||||
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);
|
||||
}
|
||||
|
||||
RoomMember
|
||||
getDirectInviteMember(const std::string &room_id)
|
||||
std::vector<RoomMember>
|
||||
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
|
||||
|
|
|
@ -83,10 +83,9 @@ getRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb);
|
|||
//! Retrieve member info from a room.
|
||||
std::vector<RoomMember>
|
||||
getMembers(const std::string &room_id, std::size_t startIndex = 0, std::size_t len = 30);
|
||||
|
||||
//! Get the other person from an invite to a direct chat.
|
||||
RoomMember
|
||||
getDirectInviteMember(const std::string &room_id);
|
||||
//! Retrive member info from an invite.
|
||||
std::vector<RoomMember>
|
||||
getMembersFromInvite(const std::string &room_id, std::size_t start_index = 0, std::size_t len = 30);
|
||||
|
||||
bool
|
||||
isInitialized();
|
||||
|
|
|
@ -110,7 +110,7 @@ public:
|
|||
std::size_t startIndex = 0,
|
||||
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 len = 30);
|
||||
size_t memberCount(const std::string &room_id);
|
||||
|
|
|
@ -165,9 +165,13 @@ RoomlistModel::data(const QModelIndex &index, int role) const
|
|||
case Roles::Tags:
|
||||
return QStringList();
|
||||
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;
|
||||
case Roles::DirectChatOtherUserId:
|
||||
return cache::getDirectInviteMember(roomid.toStdString()).user_id;
|
||||
return cache::getMembersFromInvite(roomid.toStdString(), 0, 1)
|
||||
.front()
|
||||
.user_id;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue