From efc9ba41d355caf649172f2c6fb4e5b2e6bbde1a Mon Sep 17 00:00:00 2001 From: Boris Melnik Date: Wed, 29 Mar 2023 16:26:11 +0300 Subject: [PATCH] feat(SplashScreen): Display recommendation do not close the app on re-encryption process Fixes: #10039 --- src/app/modules/startup/controller.nim | 4 ++++ src/app/modules/startup/io_interface.nim | 3 +++ src/app/modules/startup/module.nim | 5 ++++- src/app/modules/startup/view.nim | 6 +++++- src/app_service/service/accounts/service.nim | 2 ++ ui/app/mainui/SplashScreen.qml | 3 +++ ui/imports/shared/panels/DidYouKnowSplashScreen.qml | 1 + ui/imports/utils/Constants.qml | 1 + ui/main.qml | 5 +++++ 9 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/app/modules/startup/controller.nim b/src/app/modules/startup/controller.nim index 2e5c64c031..315a0f2ff7 100644 --- a/src/app/modules/startup/controller.nim +++ b/src/app/modules/startup/controller.nim @@ -170,6 +170,10 @@ proc init*(self: Controller) = self.delegate.onLocalPairingStatusUpdate(args) self.connectionIds.add(handlerId) + handlerId = self.events.onWithUUID(SIGNAL_REENCRYPTION_PROCESS_STARTED) do(e: Args): + self.delegate.onReencryptionProcessStarted() + self.connectionIds.add(handlerId) + proc shouldStartWithOnboardingScreen*(self: Controller): bool = return self.accountsService.openedAccounts().len == 0 diff --git a/src/app/modules/startup/io_interface.nim b/src/app/modules/startup/io_interface.nim index 2fdcb26661..c9e6a1d9fa 100644 --- a/src/app/modules/startup/io_interface.nim +++ b/src/app/modules/startup/io_interface.nim @@ -181,6 +181,9 @@ method validateLocalPairingConnectionString*(self: AccessInterface, connectionSt method onLocalPairingStatusUpdate*(self: AccessInterface, status: LocalPairingStatus) {.base.} = raise newException(ValueError, "No implementation available") +method onReencryptionProcessStarted*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + # This way (using concepts) is used only for the modules managed by AppController type DelegateInterface* = concept c diff --git a/src/app/modules/startup/module.nim b/src/app/modules/startup/module.nim index d5c2c0597b..c13251b795 100644 --- a/src/app/modules/startup/module.nim +++ b/src/app/modules/startup/module.nim @@ -513,4 +513,7 @@ method validateLocalPairingConnectionString*[T](self: Module[T], connectionStrin return self.controller.validateLocalPairingConnectionString(connectionString) method onLocalPairingStatusUpdate*[T](self: Module[T], status: LocalPairingStatus) = - self.view.onLocalPairingStatusUpdate(status) \ No newline at end of file + self.view.onLocalPairingStatusUpdate(status) + +method onReencryptionProcessStarted*[T](self: Module[T]) = + self.view.onReencryptionProcessStarted() \ No newline at end of file diff --git a/src/app/modules/startup/view.nim b/src/app/modules/startup/view.nim index 7adcede419..ca15c024fe 100644 --- a/src/app/modules/startup/view.nim +++ b/src/app/modules/startup/view.nim @@ -16,6 +16,7 @@ type StartupState = 0 AppLoadingState MainAppState + AppEncryptionProcessState QtObject: type @@ -353,4 +354,7 @@ QtObject: self.localPairingStatusChanged() proc validateLocalPairingConnectionString*(self: View, connectionString: string): string {.slot.} = - return self.delegate.validateLocalPairingConnectionString(connectionString) \ No newline at end of file + return self.delegate.validateLocalPairingConnectionString(connectionString) + + proc onReencryptionProcessStarted*(self: View) = + self.setAppState(AppState.AppEncryptionProcessState) \ No newline at end of file diff --git a/src/app_service/service/accounts/service.nim b/src/app_service/service/accounts/service.nim index 5e439da9ec..581cc35e13 100644 --- a/src/app_service/service/accounts/service.nim +++ b/src/app_service/service/accounts/service.nim @@ -36,6 +36,7 @@ let TEST_PEER_ENR = getEnv("TEST_PEER_ENR").string const SIGNAL_CONVERTING_PROFILE_KEYPAIR* = "convertingProfileKeypair" const SIGNAL_DERIVED_ADDRESSES_FROM_NOT_IMPORTED_MNEMONIC_FETCHED* = "derivedAddressesFromNotImportedMnemonicFetched" +const SIGNAL_REENCRYPTION_PROCESS_STARTED* = "reencryptionProcessStarted" type ResultArgs* = ref object of Args success*: bool @@ -669,6 +670,7 @@ QtObject: let isOldHashPassword = self.verifyDatabasePassword(account.keyUid, hashPassword(password, lower=false)) if isOldHashPassword: + self.events.emit(SIGNAL_REENCRYPTION_PROCESS_STARTED, Args()) discard status_privacy.lowerDatabasePassword(account.keyUid, password) let response = status_account.login( diff --git a/ui/app/mainui/SplashScreen.qml b/ui/app/mainui/SplashScreen.qml index 40b3f6ad26..380e14885f 100644 --- a/ui/app/mainui/SplashScreen.qml +++ b/ui/app/mainui/SplashScreen.qml @@ -7,6 +7,7 @@ import utils 1.0 import shared 1.0 Item { + property alias text: loadingText.text ColumnLayout { anchors.centerIn: parent LoadingAnimation { @@ -16,7 +17,9 @@ Item { source: Style.svg("status-logo-circle") } StatusBaseText { + id: loadingText Layout.alignment: Qt.AlignHCenter + horizontalAlignment: Qt.AlignHCenter text: qsTr("Loading Status...") } } diff --git a/ui/imports/shared/panels/DidYouKnowSplashScreen.qml b/ui/imports/shared/panels/DidYouKnowSplashScreen.qml index 623b89ab74..21569cc4fd 100644 --- a/ui/imports/shared/panels/DidYouKnowSplashScreen.qml +++ b/ui/imports/shared/panels/DidYouKnowSplashScreen.qml @@ -14,6 +14,7 @@ import shared.panels.private 1.0 Pane { id: root property alias progress: progressBar.value + property alias splashScreenText: splashScreen.text contentItem: Item { SplashScreen { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index fac7e52e82..f522ad1a8c 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -11,6 +11,7 @@ QtObject { readonly property int startup: 0 readonly property int appLoading: 1 readonly property int main: 2 + readonly property int appEncryptionProcess: 3 } readonly property QtObject startupFlow: QtObject { diff --git a/ui/main.qml b/ui/main.qml index 472fb09a18..d0350da18c 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -187,6 +187,11 @@ StatusWindow { Style.changeTheme(localAppSettings.theme, systemPalette.isCurrentSystemThemeDark()) Style.changeFontSize(localAccountSensitiveSettings.fontSize) Theme.updateFontSize(localAccountSensitiveSettings.fontSize) + } else if(state === Constansts.appState.appEncryptionProcess) { + loader.sourceComponent = undefined + appLoadingAnimation.active = true + appLoadingAnimation.item.splashScreenText = qsTr("Database re-encryption in progress. Please do NOT close the app.\nThis may take up to 30 minutes. Sorry for the inconvenience.\n\n This process is a one time thing and is necessary for the proper functioning of the application.") + startupOnboarding.visible = false } } }