Streamline getting other user id from invited direct chat

pull/416/head
Loren Burkholder 3 years ago
parent 0b8527eb1b
commit b9255803fb
  1. 16
      src/Cache.cpp
  2. 7
      src/Cache.h
  3. 6
      src/Cache_p.h
  4. 6
      src/timeline/RoomlistModel.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

@ -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,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);

@ -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…
Cancel
Save