Retrieve last seen time for offline room members

This commit is contained in:
miruka
2020-07-17 00:46:46 -04:00
parent a17daf61c8
commit 6c4ee17e40
5 changed files with 56 additions and 3 deletions

View File

@@ -6,10 +6,13 @@ import "../../../.."
import "../../../../Base"
import "../../../../Base/HTile"
import "../../../../Popups"
import "../../../../PythonBridge"
HTile {
id: member
property Future getPresenceFuture: null
backgroundColor: theme.chat.roomPane.listView.member.background
contentOpacity:
model.invited ? theme.chat.roomPane.listView.member.invitedOpacity : 1
@@ -145,6 +148,14 @@ HTile {
}
}
Component.onCompleted:
if (model.presence === "offline" && model.last_active_at < new Date(1))
getPresenceFuture = py.callClientCoro(
chat.userId, "get_offline_presence", [model.id],
)
Component.onDestruction: if (getPresenceFuture) getPresenceFuture.cancel()
Behavior on contentOpacity { HNumberAnimation {} }
Behavior on spacing { HNumberAnimation {} }

View File

@@ -20,6 +20,7 @@ HListView {
property bool powerLevelFieldFocused: false
property Future setPowerFuture: null
property Future getPresenceFuture: null
function loadDevices() {
py.callClientCoro(userId, "member_devices", [member.id], devices => {
@@ -269,8 +270,21 @@ HListView {
}
}
Component.onCompleted: loadDevices()
Component.onDestruction: if (setPowerFuture) setPowerFuture.cancel()
Component.onCompleted: {
loadDevices()
if (member.presence === "offline" &&
member.last_active_at < new Date(1))
{
getPresenceFuture =
py.callClientCoro(userId, "get_offline_presence", [member.id])
}
}
Component.onDestruction: {
if (setPowerFuture) setPowerFuture.cancel()
if (getPresenceFuture) getPresenceFuture.cancel()
}
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: if (! root.powerLevelFieldFocused && currentItem) {