summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-10-28 13:46:35 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-10-28 13:47:58 +0200
commit7c21c4163897e86614270ded16d27f3a2b995984 (patch)
treebdd75f598f0de7374a79fe5788b3477cc5790d79 /src
parentTranslated using Weblate (Finnish) (diff)
downloadnheko-7c21c4163897e86614270ded16d27f3a2b995984.tar.xz
fix room name calculation with 3 members
fixes #1598
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp19
1 files 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");
 }