From 9d7bffcee85c73237b2f7be02c537b944386e494 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 13 Mar 2020 12:47:01 -0400 Subject: [PATCH] Ignore alias in room with no permission to talk --- TODO.md | 3 --- src/gui/Pages/AccountSettings/Profile.qml | 2 +- src/gui/Pages/Chat/Composer.qml | 14 +++++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 41185f44..f847c7ef 100644 --- a/TODO.md +++ b/TODO.md @@ -88,9 +88,6 @@ - Code highlighting - Adapt shortcuts flicking speed to font size -- Multiaccount aliases: - - Prevent sending messages with a user not in the current room - - Accept drag and drop to upload files or set a new avatar - Improve room tooltips, e.g. show last messages - Warn user when connection is lost or 429s happen diff --git a/src/gui/Pages/AccountSettings/Profile.qml b/src/gui/Pages/AccountSettings/Profile.qml index 8e567d92..7a26ae62 100644 --- a/src/gui/Pages/AccountSettings/Profile.qml +++ b/src/gui/Pages/AccountSettings/Profile.qml @@ -202,7 +202,7 @@ HGridLayout { toolTip.text: qsTr( "From any account, start a message with specified alias " + "followed by a space to type and send as this account.\n" + - "This account must a member of the room too.\n" + + "The account must have permission to talk in the room.\n"+ "To ignore the alias when typing, prepend it with a space." ) diff --git a/src/gui/Pages/Chat/Composer.qml b/src/gui/Pages/Chat/Composer.qml index 3005a5ce..9397c4f0 100644 --- a/src/gui/Pages/Chat/Composer.qml +++ b/src/gui/Pages/Chat/Composer.qml @@ -22,7 +22,19 @@ Rectangle { property string indent: " " - property var aliases: window.settings.writeAliases + property var aliases: { + const obj = {} + + for (const [id, alia] of Object.entries(window.settings.writeAliases)){ + const room = ModelStore.get(id, "rooms").find(chat.roomId) + if (room && + ! room.inviter_id && ! room.left && room.can_send_messages) + obj[id] = alia + } + + return obj + } + property string toSend: "" property string writingUserId: chat.userId