fix(BRIDGE-90): disable repair button when bridge cannot connect to proton servers; bump GPA

This commit is contained in:
Atanas Janeshliev
2024-06-04 17:05:12 +02:00
parent cffab028b2
commit 63eb67760e
5 changed files with 24 additions and 5 deletions

View File

@ -515,7 +515,6 @@ func (bridge *Bridge) remWatcher(watcher *watcher.Watcher[events.Event]) {
func (bridge *Bridge) onStatusUp(_ context.Context) {
logPkg.Info("Handling API status up")
bridge.goLoad()
}
@ -601,3 +600,7 @@ func min(a, b time.Duration) time.Duration {
return b
}
func (bridge *Bridge) HasAPIConnection() bool {
return bridge.api.GetStatus() == proton.StatusUp
}

View File

@ -22,6 +22,7 @@ SettingsView {
property bool _isAdvancedShown: false
property var notifications
property var allUsersLoaded: false
property var hasInternetConnection: true
fillHeight: false
@ -229,13 +230,22 @@ SettingsView {
text: qsTr("Repair Bridge")
type: SettingsItem.Button
visible: root._isAdvancedShown
enabled: root.allUsersLoaded && Backend.users.count
enabled: root.allUsersLoaded && Backend.users.count && root.hasInternetConnection
onClicked: {
root.notifications.askRepairBridge();
}
Connections {
function onInternetOff() {
root.hasInternetConnection = false;
repair.description = qsTr("This feature requires internet access to the Proton servers.")
}
function onInternetOn() {
root.hasInternetConnection = true;
repair.description = qsTr("Reload all accounts, cached data, and download all emails again. Email clients stay connected to Bridge.")
}
function onAllUsersLoaded() {
root.allUsersLoaded = true;
}

View File

@ -361,7 +361,11 @@ func (f *frontendCLI) isFile(location string) bool {
}
func (f *frontendCLI) repair(_ *ishell.Context) {
if f.yesNoQuestion("Are you sure you want to initialize a repair, this may take a while") {
f.bridge.Repair()
if f.bridge.HasAPIConnection() {
if f.yesNoQuestion("Are you sure you want to initialize a repair, this may take a while") {
f.bridge.Repair()
}
} else {
f.Println("Bridge cannot connect to the Proton servers. A connection is required to utilize this feature.")
}
}