GODT-1244: Refactor switching stable-early and factory reset

This commit is contained in:
Alexander Bilyak
2021-11-03 16:55:25 +00:00
committed by Jakub
parent b5b477a3ce
commit 41e15db442
12 changed files with 163 additions and 106 deletions

View File

@ -81,13 +81,7 @@ func (f *frontendCLI) selectEarlyChannel(c *ishell.Context) {
f.Println("Bridge is currently on the stable update channel.")
if f.yesNoQuestion("Are you sure you want to switch to the early-access update channel") {
needRestart, err := f.bridge.SetUpdateChannel(updater.EarlyChannel)
if err != nil {
f.Println("There was a problem switching update channel.")
}
if needRestart {
f.restarter.SetToRestart()
}
f.bridge.SetUpdateChannel(updater.EarlyChannel)
}
}
@ -101,12 +95,6 @@ func (f *frontendCLI) selectStableChannel(c *ishell.Context) {
f.Println("Switching to the stable channel may reset all data!")
if f.yesNoQuestion("Are you sure you want to switch to the stable update channel") {
needRestart, err := f.bridge.SetUpdateChannel(updater.StableChannel)
if err != nil {
f.Println("There was a problem switching update channel.")
}
if needRestart {
f.restarter.SetToRestart()
}
f.bridge.SetUpdateChannel(updater.StableChannel)
}
}

View File

@ -79,7 +79,7 @@ SettingsView {
if (!beta.checked) {
root.notifications.askEnableBeta()
} else {
root.notifications.askDisableBeta()
root.backend.toggleBeta(false)
}
}

View File

@ -66,11 +66,6 @@ Item {
notification: root.notifications.updateForceError
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.disableBeta
}
NotificationDialog {
colorScheme: root.colorScheme
notification: root.notifications.enableBeta

View File

@ -29,7 +29,6 @@ QtObject {
property StatusWindow frontendStatus
property SystemTrayIcon frontendTray
signal askDisableBeta()
signal askEnableBeta()
signal askEnableSplitMode(var user)
signal askDisableLocalCache()
@ -58,7 +57,6 @@ QtObject {
root.updateIsLatestVersion,
root.loginConnectionError,
root.onlyPaidUsers,
root.disableBeta,
root.enableBeta,
root.bugReportSendSuccess,
root.bugReportSendError,
@ -337,41 +335,6 @@ QtObject {
}
}
property Notification disableBeta: Notification {
text: qsTr("Disable beta access?")
description: qsTr("This resets Bridge to the current release and will restart the app. Your preferences, cached data, and email client configurations will be cleared. ")
icon: "./icons/ic-exclamation-circle-filled.svg"
type: Notification.NotificationType.Warning
group: Notifications.Group.Update | Notifications.Group.Dialogs
Connections {
target: root
onAskDisableBeta: {
root.disableBeta.active = true
}
}
action: [
Action {
id: disableBeta_remindLater
text: qsTr("Remind me later")
onTriggered: {
root.disableBeta.active = false
}
},
Action {
id: disableBeta_disable
text: qsTr("Disable and restart")
onTriggered: {
root.backend.toggleBeta(false)
disableBeta_disable.loading = true
disableBeta_remindLater.enabled = false
}
}
]
}
property Notification enableBeta: Notification {
text: 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.")

View File

@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
//go:build build_qt
// +build build_qt
package qt
@ -100,31 +101,15 @@ func (f *FrontendQt) setIsBetaEnabled() {
}
func (f *FrontendQt) toggleBeta(makeItEnabled bool) {
channel := f.bridge.GetUpdateChannel()
if makeItEnabled == (channel == updater.EarlyChannel) {
f.qml.SetIsBetaEnabled(makeItEnabled)
return
}
channel = updater.StableChannel
channel := updater.StableChannel
if makeItEnabled {
channel = updater.EarlyChannel
}
needRestart, err := f.bridge.SetUpdateChannel(channel)
f.bridge.SetUpdateChannel(channel)
f.setIsBetaEnabled()
if err != nil {
f.log.WithError(err).Warn("Switching udpate channel failed.")
f.qml.UpdateManualError()
return
}
if needRestart {
f.restart()
return
}
f.checkUpdatesAndNotify(false)
// Immediately check the updates to set the correct landing page link.
f.checkUpdates()
}

View File

@ -81,7 +81,7 @@ type Bridger interface {
DisableCache() error
MigrateCache(from, to string) error
GetUpdateChannel() updater.UpdateChannel
SetUpdateChannel(updater.UpdateChannel) (needRestart bool, err error)
SetUpdateChannel(updater.UpdateChannel)
GetKeychainApp() string
SetKeychainApp(keychain string)
}