Make offline presence to stop sync

Setting the presence of an account to offline
will make the client to end sync task and will
prevent messages from being sent.

Setting it to online again or any other presence
will start sync task again.

Left:
- Local echo to presence change
- UI Control to affect all members presence
- Block more requests to be sent (e.g. member
  actions)
This commit is contained in:
vslg
2020-07-09 17:06:14 -03:00
committed by miruka
parent 3fa35b88c9
commit a3c9ac20c6
12 changed files with 231 additions and 109 deletions

View File

@@ -12,18 +12,16 @@ HMenu {
property string userId
property string presence
property string statusMsg
property bool firstSyncDone
onOpened: statusText.forceActiveFocus()
function setPresence(presence, statusMsg = null) {
function setPresence(presence, statusMsg = undefined) {
py.callClientCoro(userId, "set_presence", [presence, statusMsg])
}
HMenuItem {
enabled: firstSyncDone
icon.name: "presence"
icon.color: theme.controls.presence.online
text: qsTr("Online")
@@ -31,8 +29,7 @@ HMenu {
}
HMenuItem {
visible: presence
enabled: firstSyncDone
enabled: presence
icon.name: "presence-busy"
icon.color: theme.controls.presence.unavailable
text: qsTr("Unavailable")
@@ -40,7 +37,6 @@ HMenu {
}
HMenuItem {
enabled: firstSyncDone
icon.name: "presence-offline"
icon.color: theme.controls.presence.offline
text: qsTr("Offline")
@@ -48,8 +44,7 @@ HMenu {
}
HMenuItem {
visible: presence
enabled: firstSyncDone
enabled: presence
icon.name: "presence-invisible"
icon.color: theme.controls.presence.offline
text: qsTr("Invisible")
@@ -60,8 +55,7 @@ HMenu {
HLabeledItem {
id: statusMsgLabel
visible: presence
enabled: firstSyncDone
enabled: presence && presence !== "offline"
width: parent.width
height: visible ? implicitHeight : 0
label.text: qsTr("Status message:")
@@ -80,12 +74,14 @@ HMenu {
}
defaultText: statusMsg
placeholderText: ! presence ? "Unsupported server" : ""
Layout.fillWidth: true
}
HButton {
id: button
visible: presence
icon.name: "apply"
icon.color: theme.colors.positiveBackground