GODT-1381: Use in-memory cache in case local cache is unavailable

- change: refactor GUI notification object
- add: global bridge errors
- add: when cache on disk cannot be initialized fallback to memory cache
- add: show notification for CoD failure
- change: do not allow login to IMAP and SMTP when CoD init failed
This commit is contained in:
Alexander Bilyak
2021-11-17 13:19:37 +01:00
committed by Jakub
parent 5af3e930ec
commit b82e2ca176
15 changed files with 161 additions and 70 deletions

View File

@ -80,13 +80,13 @@ Popup {
}
switch (root.notification.type) {
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
return root.colorScheme.signal_info
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
return root.colorScheme.signal_success
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
return root.colorScheme.signal_warning
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
return root.colorScheme.signal_danger
}
}
@ -118,13 +118,13 @@ Popup {
}
switch (root.notification.type) {
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
return "./icons/ic-info-circle-filled.svg"
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
return "./icons/ic-info-circle-filled.svg"
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
return "./icons/ic-exclamation-circle-filled.svg"
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
return "./icons/ic-exclamation-circle-filled.svg"
}
}
@ -136,7 +136,7 @@ Popup {
Layout.alignment: Qt.AlignVCenter
color: root.colorScheme.text_invert
text: root.notification ? root.notification.text : ""
text: root.notification ? root.notification.description : ""
wrapMode: Text.WordWrap
}
@ -152,13 +152,13 @@ Popup {
}
switch (root.notification.type) {
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
return root.colorScheme.signal_info_active
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
return root.colorScheme.signal_success_active
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
return root.colorScheme.signal_warning_active
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
return root.colorScheme.signal_danger_active
}
}
@ -190,22 +190,22 @@ Popup {
var active
switch (root.notification.type) {
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
norm = root.colorScheme.signal_info
hover = root.colorScheme.signal_info_hover
active = root.colorScheme.signal_info_active
break;
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
norm = root.colorScheme.signal_success
hover = root.colorScheme.signal_success_hover
active = root.colorScheme.signal_success_active
break;
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
norm = root.colorScheme.signal_warning
hover = root.colorScheme.signal_warning_hover
active = root.colorScheme.signal_warning_active
break;
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
norm = root.colorScheme.signal_danger
hover = root.colorScheme.signal_danger_hover
active = root.colorScheme.signal_danger_active

View File

@ -52,6 +52,13 @@ QtObject {
onVisibleChanged: {
backend.dockIconVisible = visible
}
Connections {
target: root.backend
onCacheUnavailable: {
mainWindow.showAndRise()
}
}
}
property StatusWindow _statusWindow: StatusWindow {

View File

@ -55,12 +55,12 @@ Dialog {
}
switch (root.notification.type) {
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
return "./icons/ic-info.svg"
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
return "./icons/ic-success.svg"
case Notification.NotificationType.Warning:
case Notification.NotificationType.Danger:
case Notification.NotificationType.Warning:
case Notification.NotificationType.Danger:
return "./icons/ic-alert.svg"
}
}
@ -70,7 +70,7 @@ Dialog {
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 8
colorScheme: root.colorScheme
text: root.notification.text
text: root.notification.title
type: Label.LabelType.Title
}

View File

@ -30,8 +30,13 @@ QtObject {
Danger = 3
}
property string text
// title is used in dialogs only
property string title
// description is used in banners and in dialogs as description
property string description
// brief is used in status view only
property string brief
property string icon
property list<Action> action
property int type

View File

@ -74,7 +74,8 @@ QtObject {
// Connection
property Notification noInternet: Notification {
text: qsTr("No connection")
description: qsTr("Bridge is not able to contact the server, please check your internet connection.")
brief: qsTr("No connection")
icon: "./icons/ic-no-connection.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Connection
@ -93,8 +94,9 @@ QtObject {
// Updates
property Notification updateManualReady: Notification {
text: qsTr("Update to Bridge") + " " + (data ? data.version : "")
title: qsTr("Update to Bridge %1").arg(data ? data.version : "")
description: qsTr("A new version of ProtonMail Bridge is available. See what's changed.")
brief: qsTr("Update available. (See what's new.)")
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Info
group: Notifications.Group.Update | Notifications.Group.Dialogs
@ -135,7 +137,8 @@ QtObject {
}
property Notification updateManualRestartNeeded: Notification {
text: qsTr("Bridge update is ready")
description: qsTr("Bridge update is ready")
brief: description
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Info
group: Notifications.Group.Update
@ -158,7 +161,8 @@ QtObject {
}
property Notification updateManualError: Notification {
text: qsTr("Bridge couldnt update. Please update manually.")
description: qsTr("Bridge couldnt update")
brief: description
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Update
@ -190,8 +194,9 @@ QtObject {
}
property Notification updateForce: Notification {
text: qsTr("Update to ProtonMail Bridge") + " " + (data ? data.version : "")
title: qsTr("Update to Bridge %1").arg(data ? data.version : "")
description: qsTr("This version of Bridge is no longer supported, please update.")
brief: qsTr("Bridge is outdated")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Update | Notifications.Group.Dialogs
@ -234,8 +239,9 @@ QtObject {
}
property Notification updateForceError: Notification {
text: qsTr("Bridge coudnt update")
description: qsTr("You must update manually.")
title: qsTr("Bridge coudnt update")
description: qsTr("You must update manually. Go to: https:/protonmail.com/bridge/download")
brief: title
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Update | Notifications.Group.Dialogs
@ -269,7 +275,8 @@ QtObject {
}
property Notification updateSilentRestartNeeded: Notification {
text: qsTr("Bridge update is ready")
description: qsTr("Bridge update is ready")
brief: description
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Info
group: Notifications.Group.Update
@ -292,7 +299,8 @@ QtObject {
}
property Notification updateSilentError: Notification {
text: qsTr("Bridge couldnt update")
description: qsTr("Bridge couldnt update")
brief: description
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Update
@ -315,7 +323,7 @@ QtObject {
}
property Notification updateIsLatestVersion: Notification {
text: qsTr("Bridge is up to date")
description: qsTr("Bridge is up to date")
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Info
group: Notifications.Group.Update
@ -337,7 +345,7 @@ QtObject {
}
property Notification enableBeta: Notification {
text: qsTr("Enable Beta access")
title: qsTr("Enable Beta access")
description: qsTr("Be the first to get new updates and use new features. Bridge will update to the latest beta version.")
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Info
@ -370,7 +378,7 @@ QtObject {
// login
property Notification loginConnectionError: Notification {
text: qsTr("Bridge is not able to contact the server, please check your internet connection.")
description: qsTr("Bridge is not able to contact the server, please check your internet connection.")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Configuration
@ -393,7 +401,7 @@ QtObject {
}
property Notification onlyPaidUsers: Notification {
text: qsTr("Bridge is exclusive to our paid plans. Upgrade your account to use Bridge.")
description: qsTr("Bridge is exclusive to our paid plans. Upgrade your account to use Bridge.")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Configuration
@ -416,7 +424,7 @@ QtObject {
}
property Notification alreadyLoggedIn: Notification {
text: qsTr("This account is already signed it.")
description: qsTr("This account is already signed it.")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Info
group: Notifications.Group.Configuration
@ -440,7 +448,7 @@ QtObject {
// Bug reports
property Notification bugReportSendSuccess: Notification {
text: qsTr("Thank you for the report. We'll get back to you as soon as we can.")
description: qsTr("Thank you for the report. We'll get back to you as soon as we can.")
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Success
group: Notifications.Group.Configuration
@ -463,7 +471,7 @@ QtObject {
}
property Notification bugReportSendError: Notification {
text: qsTr("Report could not be sent. Try again or email us directly.")
description: qsTr("Report could not be sent. Try again or email us directly.")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Configuration
@ -485,8 +493,9 @@ QtObject {
// Cache
property Notification cacheUnavailable: Notification {
text: qsTr("Cache location is unavailable")
title: qsTr("Cache location is unavailable")
description: qsTr("Check the directory or change it in your settings.")
brief: qsTr("The current cache location is unavailable. Check the directory or change it in your settings.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -516,7 +525,7 @@ QtObject {
}
property Notification cacheCantMove: Notification {
text: qsTr("Cant move cache")
title: qsTr("Cant move cache")
description: qsTr("The location you have selected is not available. Make sure you have enough free space or choose another location.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -546,7 +555,7 @@ QtObject {
}
property Notification cacheLocationChangeSuccess: Notification {
text: qsTr("Cache location successfully changed")
description: qsTr("Cache location successfully changed")
icon: "./icons/ic-info-circle-filled.svg"
type: Notification.NotificationType.Success
group: Notifications.Group.Configuration
@ -571,7 +580,8 @@ QtObject {
// Other
property Notification accountChanged: Notification {
text: qsTr("The address list for your account has changed")
description: qsTr("The address list for .... account has changed. You need to reconfigure your email client.")
brief: qsTr("The address list for your account has changed. Reconfigure your email client.")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Danger
group: Notifications.Group.Configuration
@ -586,8 +596,9 @@ QtObject {
}
property Notification diskFull: Notification {
text: qsTr("Your disk is almost full")
title: qsTr("Your disk is almost full")
description: qsTr("Quit Bridge and free disk space or disable the local cache (not recommended).")
brief: qsTr("Your disk is almost full. Free disk space or disable the local cache.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -617,8 +628,8 @@ QtObject {
}
property Notification enableSplitMode: Notification {
text: qsTr("Enable split mode?")
description: qsTr("Changing between split and combined address mode will require you to delete your accounts(s) from your email client and begin the setup process from scratch.")
title: qsTr("Enable split mode?")
description: qsTr("Changing between split and combined address mode will require you to delete your account(s) from your email client and begin the setup process from scratch.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -632,7 +643,6 @@ QtObject {
}
}
Connections {
target: (root && root.enableSplitMode && root.enableSplitMode.user ) ? root.enableSplitMode.user : null
onToggleSplitModeFinished: {
@ -664,7 +674,7 @@ QtObject {
}
property Notification disableLocalCache: Notification {
text: qsTr("Disable local cache?")
title: qsTr("Disable local cache?")
description: qsTr("This action will clear your local cache, including locally stored messages. Bridge will restart.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -676,7 +686,6 @@ QtObject {
}
}
Connections {
target: root.backend
onChangeLocalCacheFinished: {
@ -708,7 +717,7 @@ QtObject {
}
property Notification enableLocalCache: Notification {
text: qsTr("Enable local cache?")
title: qsTr("Enable local cache")
description: qsTr("Bridge will restart.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -723,7 +732,6 @@ QtObject {
}
}
Connections {
target: root.backend
onChangeLocalCacheFinished: {
@ -755,7 +763,7 @@ QtObject {
}
property Notification resetBridge: Notification {
text: qsTr("Reset Bridge?")
title: qsTr("Reset Bridge?")
description: qsTr("This will clear your accounts, preferences, and cached data. You will need to reconfigure your email client. Bridge will automatically restart.")
type: Notification.NotificationType.Warning
group: Notifications.Group.Configuration | Notifications.Group.Dialogs
@ -769,7 +777,6 @@ QtObject {
}
}
Connections {
target: root.backend
onResetFinished: {

View File

@ -56,22 +56,22 @@ Item {
}
image.source = topmost.icon
label.text = topmost.text
label.text = topmost.brief
switch (topmost.type) {
case Notification.NotificationType.Danger:
case Notification.NotificationType.Danger:
image.color = root.colorScheme.signal_danger
label.color = root.colorScheme.signal_danger
break;
case Notification.NotificationType.Warning:
case Notification.NotificationType.Warning:
image.color = root.colorScheme.signal_warning
label.color = root.colorScheme.signal_warning
break;
case Notification.NotificationType.Success:
case Notification.NotificationType.Success:
image.color = root.colorScheme.signal_success
label.color = root.colorScheme.signal_success
break;
case Notification.NotificationType.Info:
case Notification.NotificationType.Info:
image.color = root.colorScheme.signal_info
label.color = root.colorScheme.signal_info
break;

View File

@ -128,7 +128,7 @@ Window {
Layout.topMargin: 12
Layout.bottomMargin: 12
visible: (statusItem.activeNotification && statusItem.activeNotification.action) ? true : false
visible: statusItem.activeNotification && statusItem.activeNotification.action.length > 0
action: statusItem.activeNotification && statusItem.activeNotification.action.length > 0 ? statusItem.activeNotification.action[0] : null
}
}