diff --git a/go.mod b/go.mod index c3351eeb..91a44c52 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/Masterminds/semver/v3 v3.2.0 github.com/ProtonMail/gluon v0.17.1-0.20240514133734-79cdd0fec41c github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a - github.com/ProtonMail/go-proton-api v0.4.1-0.20240423123404-a6163268401c + github.com/ProtonMail/go-proton-api v0.4.1-0.20240605113119-1a81ec7dc72d github.com/ProtonMail/gopenpgp/v2 v2.7.4-proton github.com/PuerkitoBio/goquery v1.8.1 github.com/abiosoft/ishell v2.0.0+incompatible diff --git a/go.sum b/go.sum index 76826dbc..c0bb73d0 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,8 @@ github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ek github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw= github.com/ProtonMail/go-proton-api v0.4.1-0.20240423123404-a6163268401c h1:3U245DPGyL+LeAcJzFSg+E2lShXx+z/lBHM2v9P5mEg= github.com/ProtonMail/go-proton-api v0.4.1-0.20240423123404-a6163268401c/go.mod h1:3A0cpdo0BIenIPjTG6u8EbzJ8uuJy7rVvM/NaynjCKA= +github.com/ProtonMail/go-proton-api v0.4.1-0.20240605113119-1a81ec7dc72d h1:B9/ZLubPWIY4uvATviFoCUoLauq98C3Bbt4v0A2VEdU= +github.com/ProtonMail/go-proton-api v0.4.1-0.20240605113119-1a81ec7dc72d/go.mod h1:3A0cpdo0BIenIPjTG6u8EbzJ8uuJy7rVvM/NaynjCKA= github.com/ProtonMail/go-smtp v0.0.0-20231109081432-2b3d50599865 h1:EP1gnxLL5Z7xBSymE9nSTM27nRYINuvssAtDmG0suD8= github.com/ProtonMail/go-smtp v0.0.0-20231109081432-2b3d50599865/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ= github.com/ProtonMail/go-srp v0.0.7 h1:Sos3Qk+th4tQR64vsxGIxYpN3rdnG9Wf9K4ZloC1JrI= diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index b90676d9..cf0b86fa 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -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 +} diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/GeneralSettings.qml b/internal/frontend/bridge-gui/bridge-gui/qml/GeneralSettings.qml index 9f95b4fa..0ef91bc4 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/GeneralSettings.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/GeneralSettings.qml @@ -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; } diff --git a/internal/frontend/cli/system.go b/internal/frontend/cli/system.go index 12f09084..c9591303 100644 --- a/internal/frontend/cli/system.go +++ b/internal/frontend/cli/system.go @@ -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.") } }