diff options
-rw-r--r-- | src/Cache.cpp | 16 | ||||
-rw-r--r-- | src/Cache.h | 7 | ||||
-rw-r--r-- | src/Cache_p.h | 6 | ||||
-rw-r--r-- | src/timeline/RoomlistModel.cpp | 6 |
4 files changed, 15 insertions, 20 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp index 6be61633..b1fd0ce0 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -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 diff --git a/src/Cache.h b/src/Cache.h index 2c024722..f8626430 100644 --- a/src/Cache.h +++ b/src/Cache.h @@ -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(); diff --git a/src/Cache_p.h b/src/Cache_p.h index d4605048..e98b1c34 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h @@ -110,9 +110,9 @@ public: std::size_t startIndex = 0, std::size_t len = 30); - std::vector<RoomMember> getMembersFromInvitedRoom(const std::string &room_id, - std::size_t startIndex = 0, - std::size_t len = 30); + 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); void saveState(const mtx::responses::Sync &res); diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp index c29e1adf..afe53560 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp @@ -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 {}; } |