From 7c21c4163897e86614270ded16d27f3a2b995984 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 28 Oct 2023 13:46:35 +0200 Subject: [PATCH] fix room name calculation with 3 members fixes #1598 --- src/Cache.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Cache.cpp b/src/Cache.cpp index f110fef3..25904e53 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -3123,11 +3123,26 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) return localUserId_; }(); + auto second_member = [&members, this]() { + bool first = true; + for (const auto &m : members) { + if (m.first != localUserId_.toStdString()) { + if (first) + first = false; + else + return QString::fromStdString(m.second.name); + } + } + + return localUserId_; + }(); if (total == 2) return first_member; - else if (total > 2) - return tr("%1 and %n other(s)", "", (int)total - 1).arg(first_member); + else if (total == 3) + return tr("%1 and %2", "RoomName").arg(first_member, second_member); + else if (total > 3) + return tr("%1 and %n other(s)", "", (int)total - 2).arg(first_member); return tr("Empty Room"); }