Skip to content

Commit

Permalink
feat(SplashScreen): Display recommendation do not close the app on re…
Browse files Browse the repository at this point in the history
…-encryption process

Fixes: #10039
  • Loading branch information
borismelnik committed Mar 29, 2023
1 parent 5479880 commit 5ee05b0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/modules/startup/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/app/modules/startup/io_interface.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/app/modules/startup/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
self.view.onLocalPairingStatusUpdate(status)

method onReencryptionProcessStarted*[T](self: Module[T]) =
self.view.onReencryptionProcessStarted()
6 changes: 5 additions & 1 deletion src/app/modules/startup/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type
StartupState = 0
AppLoadingState
MainAppState
AppEncryptionProcessState

QtObject:
type
Expand Down Expand Up @@ -353,4 +354,7 @@ QtObject:
self.localPairingStatusChanged()

proc validateLocalPairingConnectionString*(self: View, connectionString: string): string {.slot.} =
return self.delegate.validateLocalPairingConnectionString(connectionString)
return self.delegate.validateLocalPairingConnectionString(connectionString)

proc onReencryptionProcessStarted*(self: View) =
self.setAppState(AppState.AppEncryptionProcessState)
2 changes: 2 additions & 0 deletions src/app_service/service/accounts/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions ui/app/mainui/SplashScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import utils 1.0
import shared 1.0

Item {
property alias text: loadingText.text
ColumnLayout {
anchors.centerIn: parent
LoadingAnimation {
Expand All @@ -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...")
}
}
Expand Down
1 change: 1 addition & 0 deletions ui/imports/shared/panels/DidYouKnowSplashScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 5ee05b0

Please # to comment.