GODT-1770: handle UserBadEvent in CLI and gRPC.

This commit is contained in:
Xavier Michelon
2023-01-23 14:53:44 +01:00
parent f019ba3713
commit 5a70a16149
23 changed files with 1591 additions and 572 deletions

View File

@ -399,4 +399,20 @@ Item {
signIn.username = username
rightContent.showSignIn()
}
function selectUser(userID) {
var users = Backend.users;
for (var i = 0; i < users.count; i++) {
var user = users.get(i)
if (user.id !== userID) {
continue;
}
accounts.currentIndex = i;
if (user.state === EUserState.SignedOut)
showSignIn(user.primaryEmailOrUsername())
return;
}
console.error("User with ID ", userID, " was not found in the account list")
}
}

View File

@ -86,6 +86,10 @@ ApplicationWindow {
root.showAndRise()
}
function onSelectUser(userID) {
root.selectUser(userID)
}
function onLoginFinished(index, wasSignedOut) {
var user = Backend.users.get(index)
if (user && !wasSignedOut) {
@ -182,6 +186,7 @@ ApplicationWindow {
function showLocalCacheSettings() { contentWrapper.showLocalCacheSettings() }
function showSettings() { contentWrapper.showSettings() }
function showHelp() { contentWrapper.showHelp() }
function selectUser(userID) { contentWrapper.selectUser(userID) }
function showSignIn(username) {
if (contentLayout.currentIndex == 1) return

View File

@ -80,6 +80,7 @@ QtObject {
root.addressChanged,
root.apiCertIssue,
root.noActiveKeyForRecipient,
root.userBadEvent,
root.genericError
]
@ -1101,6 +1102,33 @@ QtObject {
]
}
property Notification userBadEvent: Notification {
title: qsTr("User was logged out")
brief: title
description: "#PlaceHolderText"
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Connection
Connections {
target: Backend
function onUserBadEvent(message) {
root.userBadEvent.description = message
root.userBadEvent.active = true
}
}
action: [
Action {
text: qsTr("OK")
onTriggered: {
root.userBadEvent.active = false
}
}
]
}
property Notification genericError: Notification {
title: "#PlaceholderText#"
description: "#PlaceholderText#"