From a1fb3471c9c316eb7d79540c011c747aabf14ae2 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Tue, 23 Mar 2021 22:38:25 +0100 Subject: [PATCH] Limit the reaction tooltip to 3 users --- .../Component/Timeline/ReactionDelegate.qml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/imports/NeoChat/Component/Timeline/ReactionDelegate.qml b/imports/NeoChat/Component/Timeline/ReactionDelegate.qml index 969e5d385..677f08d06 100644 --- a/imports/NeoChat/Component/Timeline/ReactionDelegate.qml +++ b/imports/NeoChat/Component/Timeline/ReactionDelegate.qml @@ -46,17 +46,21 @@ Flow { ToolTip.text: { var text = ""; - for (var i = 0; i < modelData.authors.length; i++) { - if (i === modelData.authors.length - 1 && i !== 0) { - text += i18nc("Separate the usernames of users", " and ") - } else if (i !== 0) { - text += ", " + for (var i = 0; i < modelData.authors.length && i < 3; i++) { + if (i !== 0) { + if (i < modelData.authors.length - 1) { + text += ", " + } else { + text += i18nc("Separate the usernames of users", " and ") + } } - text += modelData.authors[i].displayName } + if (modelData.authors.length > 3) { + text += i18ncp("%1 is the number of other users", " and %1 other", " and %1 others", modelData.authors.length - 3) + } - text = i18ncp("%1 is the users who reacted and %2 the emoji that was given", "%2 reacted with %3", "%2 reacted with %3", modelData.authors.length, text, modelData.reaction) + text = i18ncp("%2 is the users who reacted and %3 the emoji that was given", "%2 reacted with %3", "%2 reacted with %3", modelData.authors.length, text, modelData.reaction) return text }