Add account logout feature via context menu
This commit is contained in:
@@ -21,7 +21,7 @@ HPage {
|
||||
|
||||
onRoomInfoChanged: {
|
||||
if (roomInfo.left) {
|
||||
// The room will most likely be gone on client restart
|
||||
// If left, the room will most likely be gone on client restart
|
||||
window.uiState.page = "Pages/Default.qml"
|
||||
window.uiState.pageProperties = {}
|
||||
window.uiStateChanged()
|
||||
|
@@ -25,6 +25,7 @@ HPage {
|
||||
Utils.coloredNameHtml(headerName, userId)
|
||||
)
|
||||
|
||||
|
||||
HSpacer {}
|
||||
|
||||
Repeater {
|
||||
|
@@ -19,6 +19,7 @@ HTileDelegate {
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
|
||||
|
||||
property bool disconnecting: false
|
||||
readonly property bool forceExpand: Boolean(accountRoomList.filter)
|
||||
|
||||
// Hide harmless error when a filter matches nothing
|
||||
@@ -27,9 +28,11 @@ HTileDelegate {
|
||||
} catch (err) {}
|
||||
|
||||
|
||||
onActivated: pageLoader.showPage(
|
||||
"EditAccount/EditAccount", { "userId": model.data.user_id }
|
||||
)
|
||||
onActivated: if (! disconnecting) {
|
||||
pageLoader.showPage(
|
||||
"EditAccount/EditAccount", { "userId": model.data.user_id }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
function toggleCollapse() {
|
||||
@@ -70,4 +73,29 @@ HTileDelegate {
|
||||
|
||||
Behavior on opacity { HNumberAnimation {} }
|
||||
}
|
||||
|
||||
contextMenu: HMenu {
|
||||
HMenuItem {
|
||||
icon.name: "logout"
|
||||
text: qsTr("Logout")
|
||||
onTriggered: {
|
||||
disconnecting = true
|
||||
|
||||
let page = window.uiState.page
|
||||
let userId = model.data.user_id
|
||||
|
||||
if ((modelSources["Account"] || []).length < 2) {
|
||||
pageLoader.showPage("SignIn")
|
||||
}
|
||||
else if ((page == "Pages/EditAccount/EditAccount.qml" ||
|
||||
page == "Chat/Chat.qml") &&
|
||||
window.uiState.pageProperties.userId == userId)
|
||||
{
|
||||
pageLoader.showPage("Default")
|
||||
}
|
||||
|
||||
py.callCoro("logout_client", [userId])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user