diff --git a/src/app/boot/app_controller.nim b/src/app/boot/app_controller.nim index 227c495fbf..266498ec0d 100644 --- a/src/app/boot/app_controller.nim +++ b/src/app/boot/app_controller.nim @@ -268,6 +268,8 @@ proc startupDidLoad*(self: AppController) = # We need to init a language service once qml is loaded self.languageService.init() + # We need this to set app width/height appropriatelly on the app start. + self.startupModule.startUpUIRaised() proc mainDidLoad*(self: AppController) = self.statusFoundation.onLoggedIn() @@ -276,6 +278,7 @@ proc mainDidLoad*(self: AppController) = self.mainModule.checkForStoringPassword() proc start*(self: AppController) = + self.keychainService.init() self.generalService.init() self.ethService.init() self.accountsService.init() diff --git a/src/app/modules/startup/module.nim b/src/app/modules/startup/module.nim index 3e1edbbd5d..81a2618317 100644 --- a/src/app/modules/startup/module.nim +++ b/src/app/modules/startup/module.nim @@ -81,5 +81,8 @@ method userLoggedIn*[T](self: Module[T]) = method moveToAppState*[T](self: Module[T]) = self.view.setAppState(AppState.MainAppState) +method startUpUIRaised*[T](self: Module[T]) = + self.view.startUpUIRaised() + method emitLogOut*[T](self: Module[T]) = self.view.emitLogOut() \ No newline at end of file diff --git a/src/app/modules/startup/private_interfaces/module_access_interface.nim b/src/app/modules/startup/private_interfaces/module_access_interface.nim index 30139ef0f9..65a660a2fd 100644 --- a/src/app/modules/startup/private_interfaces/module_access_interface.nim +++ b/src/app/modules/startup/private_interfaces/module_access_interface.nim @@ -5,4 +5,7 @@ method load*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") method moveToAppState*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method startUpUIRaised*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/startup/view.nim b/src/app/modules/startup/view.nim index 5cc0acb9dd..5d91f3d24e 100644 --- a/src/app/modules/startup/view.nim +++ b/src/app/modules/startup/view.nim @@ -26,6 +26,7 @@ QtObject: # In some point, here, we will setup some exposed main module related things. self.delegate.viewDidLoad() + proc startUpUIRaised*(self: View) {.signal.} proc appStateChanged*(self: View, state: int) {.signal.} proc getAppState(self: View): int {.slot.} = diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index d115229796..cb651dccf7 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -75,7 +75,6 @@ QtObject: result.events = events result.threadpool = threadpool result.contacts = initTable[string, ContactsDto]() - signalConnect(singletonInstance.userProfile, "imageChanged()", result, "onLoggedInUserImageChange()", 2) proc addContact(self: Service, contact: ContactsDto) = # Private proc, used for adding contacts only. @@ -125,6 +124,8 @@ QtObject: self.doConnect() self.startCheckingContactStatuses() + signalConnect(singletonInstance.userProfile, "imageChanged()", self, "onLoggedInUserImageChange()", 2) + proc onLoggedInUserImageChange*(self: Service) {.slot.} = let data = Args() self.events.emit(SIGNAL_LOGGEDIN_USER_IMAGE_CHANGED, data) diff --git a/src/app_service/service/keychain/service.nim b/src/app_service/service/keychain/service.nim index 12147a604d..b5a6361055 100644 --- a/src/app_service/service/keychain/service.nim +++ b/src/app_service/service/keychain/service.nim @@ -22,11 +22,6 @@ QtObject: proc setup(self: Service) = self.QObject.setup - self.keychainManager = newStatusKeychainManager("StatusDesktop", "authenticate you") - signalConnect(self.keychainManager, "success(QString)", self, - "onKeychainManagerSuccess(QString)", 2) - signalConnect(self.keychainManager, "error(QString, int, QString)", self, - "onKeychainManagerError(QString, int, QString)", 2) proc delete*(self: Service) = self.keychainManager.delete @@ -36,6 +31,13 @@ QtObject: new(result, delete) result.setup() result.events = events + result.keychainManager = newStatusKeychainManager("StatusDesktop", "authenticate you") + + proc init*(self: Service) = + signalConnect(self.keychainManager, "success(QString)", self, + "onKeychainManagerSuccess(QString)", 2) + signalConnect(self.keychainManager, "error(QString, int, QString)", self, + "onKeychainManagerError(QString, int, QString)", 2) proc storePassword*(self: Service, username: string, password: string) = self.keychainManager.storeDataAsync(username, password) diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index f3e4e4e733..a4e2f092bc 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -94,10 +94,6 @@ proc mainProc() = # Register events objects let dockShowAppEvent = newStatusDockShowAppEventObject(singletonInstance.engine) let osThemeEvent = newStatusOSThemeEventObject(singletonInstance.engine) - # We need this global variable in order to be able to access the application - # from the non-closure callback passed to `statusgo_backend.setSignalEventCallback` - signalsManagerQObjPointer = cast[pointer](statusFoundation.signalsManager.vptr) - setupRemoteSignalsHandling() if not defined(macosx): app.icon(app.applicationDirPath & statusAppIconPath) @@ -139,6 +135,12 @@ proc mainProc() = info "starting application controller..." appController.start() + + # We need this global variable in order to be able to access the application + # from the non-closure callback passed to `statusgo_backend.setSignalEventCallback` + signalsManagerQObjPointer = cast[pointer](statusFoundation.signalsManager.vptr) + setupRemoteSignalsHandling() + info "starting application..." app.exec() diff --git a/test-scripts/app-run-test.sh b/test-scripts/app-run-test.sh new file mode 100755 index 0000000000..754c352ee4 --- /dev/null +++ b/test-scripts/app-run-test.sh @@ -0,0 +1,40 @@ +## This script runs the app in a loop for `TOTAL_NUM_OF_TRIES` times and closes it +## after each successful run. If all runs go well, script will place a success message, +## otherwise you will get an error and an info in which run an error occurred. +## +## Tested on MacOs! +## +## You need to build the app before running this script. + +TOTAL_NUM_OF_TRIES=100 +COUNTER=0 +RES=1 +PID=-1 + +function checkSuccess { + if [ "$RES" -eq "0" ]; then + printf "\x1B[1;32m$1\x1B[0m\n"; + else + printf "\x1B[1;31m$2\x1B[0m\n"; exit 1 + fi +} + +while [ $COUNTER -lt $TOTAL_NUM_OF_TRIES ] +do + echo "------------------------------------" + ((COUNTER=COUNTER+1)) + echo "Running the app..." + export LD_LIBRARY_PATH=vendor/status-lib/vendor/status-go/build/bin/libstatus.so & + ./bin/nim_status_client & + PID=$! + sleep 4 + output=$(ps -p "$PID") + RES=$? + checkSuccess "App successfully started in PID{$PID} for the $COUNTER. time" "An error starting the app occurred in $COUNTER. try" + echo "Closing the app..." + kill -9 $PID + sleep 3 + echo "------------------------------------" +done + +printf "\x1B[1;32m ALL $TOTAL_NUM_OF_TRIES TRIES WERE SUCCESSFUL! \x1B[0m\n"; \ No newline at end of file diff --git a/ui/main.qml b/ui/main.qml index 732b4734c4..c3c8145938 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -23,6 +23,7 @@ StatusWindow { property bool hasAccounts: startupModule.appState !== Constants.appState.onboarding property alias dragAndDrop: dragTarget property bool displayBeforeGetStartedModal: !hasAccounts + property bool appIsReady: false Universal.theme: Universal.System @@ -44,10 +45,14 @@ StatusWindow { visible: true function storeWidth() { + if(!applicationWindow.appIsReady) + return localAppSettings.appWidth = width } function storeHeight() { + if(!applicationWindow.appIsReady) + return localAppSettings.appHeight = height } @@ -94,6 +99,13 @@ StatusWindow { Connections { target: startupModule + + onStartUpUIRaised: { + applicationWindow.appIsReady = true + applicationWindow.storeWidth() + applicationWindow.storeHeight() + } + onAppStateChanged: { if(state === Constants.appState.main) { // We set main module to the Global singleton once user is logged in and we move to the main app.