summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-12-30 04:54:03 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-12-30 04:54:03 +0100
commit9a9dbda571a674ecfbf23533c64ec9cb095479ef (patch)
tree3e4ac7250ec9bedc7285c5aec144eb496a08e62e /resources
parentConvert blurhash image format on worker thread (diff)
downloadnheko-9a9dbda571a674ecfbf23533c64ec9cb095479ef.tar.xz
Update presence dynamically and reduce allocations
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/Avatar.qml18
-rw-r--r--resources/qml/MessageView.qml11
2 files changed, 25 insertions, 4 deletions
diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml

index 27d139d4..b055d452 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml
@@ -87,14 +87,18 @@ Rectangle { } Rectangle { + id: onlineIndicator + anchors.bottom: avatar.bottom anchors.right: avatar.right visible: !!userid height: avatar.height / 6 width: height radius: Settings.avatarCircles ? height / 2 : height / 8 - color: { - switch (TimelineManager.userPresence(userid)) { + color: updatePresence() + + function updatePresence() { + switch (Presence.userPresence(userid)) { case "online": return "#00cc66"; case "unavailable": @@ -102,7 +106,15 @@ Rectangle { case "offline": default: // return "#a82353" don't show anything if offline, since it is confusing, if presence is disabled - "transparent"; + return "transparent"; + } + } + + Connections { + target: Presence + + function onPresenceChanged(id) { + if (id == userid) onlineIndicator.color = onlineIndicator.updatePresence(); } } } diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 62f7735b..adbc9d70 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml
@@ -329,12 +329,21 @@ ScrollView { } Label { + id: statusMsg color: Nheko.colors.buttonText - text: TimelineManager.userStatus(userId) + text: Presence.userStatus(userId) textFormat: Text.PlainText elide: Text.ElideRight width: chat.delegateMaxWidth - parent.spacing * 2 - userName.implicitWidth - Nheko.avatarSize font.italic: true + + Connections { + target: Presence + + function onPresenceChanged(id) { + if (id == userId) statusMsg.text = Presence.userStatus(userId); + } + } } }