fix: multiple issues running the app

- `setAppWidth` issue - fixed
- `signal connection` issue - fixed
- `app-run-test.sh` script added
This commit is contained in:
Sale Djenic 2022-01-27 16:29:17 +01:00
parent eb41dbe175
commit 4169854feb
9 changed files with 77 additions and 10 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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")

View File

@ -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.} =

View File

@ -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)

View File

@ -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)

View File

@ -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()

40
test-scripts/app-run-test.sh Executable file
View File

@ -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";

View File

@ -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.