From 4587599cf5c4b062d27e6b3da10eb5c5a8c62d3c Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 30 Aug 2019 10:49:41 -0400 Subject: [PATCH] Fix sending typing state when no configured alias --- TODO.md | 1 - src/qml/Chat/Composer.qml | 8 ++++++++ src/qml/utils.js | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 8d8f2501..078c4e79 100644 --- a/TODO.md +++ b/TODO.md @@ -15,7 +15,6 @@ - Using up/down when sidepane focused - Missing hourglass when changing avatar and applying - Icons on KDE - - Send typing state when no alias - Greentext for local echo - Show error if uploading avatar fails diff --git a/src/qml/Chat/Composer.qml b/src/qml/Chat/Composer.qml index 134d889f..9cb806a9 100644 --- a/src/qml/Chat/Composer.qml +++ b/src/qml/Chat/Composer.qml @@ -82,6 +82,14 @@ Rectangle { } onTextChanged: { + if (Utils.isEmptyObject(aliases)) { + writingUserId = Qt.binding(() => chatPage.userId) + toSend = text + setTyping(Boolean(text)) + textChangedSinceLostFocus = true + return + } + let foundAlias = null for (let [user, writing_alias] of Object.entries(aliases)) { diff --git a/src/qml/utils.js b/src/qml/utils.js index c5c85b20..897c2235 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -1,3 +1,8 @@ +function isEmptyObject(obj) { + return Object.entries(obj).length === 0 && obj.constructor === Object +} + + function numberWrapAround(num, max) { return num < 0 ? max + (num % max) : (num % max) }