-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@desktop/onboarding): onboarding flows for
I already use Status
…
… path do not match figma requirements (2/2) Continuation: desktop app updated after we decided to remove 30 secs waiting time from `status-go` and introduce it on the desktop app side.
- Loading branch information
1 parent
19ba018
commit 6b6aaf3
Showing
11 changed files
with
91 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,87 @@ | ||
import os, json, chronicles | ||
import NimQml, os, json, chronicles | ||
|
||
import ../../../backend/general as status_general | ||
import ../../../app/core/eventemitter | ||
import ../../../app/core/tasks/[qt, threadpool] | ||
import ../../../constants as app_constants | ||
|
||
import ../accounts/dto/accounts | ||
|
||
const TimerIntervalInMilliseconds = 1000 # 1 second | ||
|
||
const SIGNAL_GENERAL_TIMEOUT* = "timeoutSignal" | ||
|
||
logScope: | ||
topics = "general-app-service" | ||
|
||
type | ||
Service* = ref object of RootObj | ||
include ../../common/async_tasks | ||
|
||
QtObject: | ||
type Service* = ref object of QObject | ||
events: EventEmitter | ||
threadpool: ThreadPool | ||
timeoutInMilliseconds: int | ||
|
||
proc delete*(self: Service) = | ||
self.QObject.delete | ||
|
||
proc newService*(events: EventEmitter, threadpool: ThreadPool): Service = | ||
new(result, delete) | ||
result.QObject.setup | ||
result.events = events | ||
result.threadpool = threadpool | ||
|
||
proc init*(self: Service) = | ||
if not existsDir(app_constants.ROOTKEYSTOREDIR): | ||
createDir(app_constants.ROOTKEYSTOREDIR) | ||
|
||
proc delete*(self: Service) = | ||
discard | ||
proc startMessenger*(self: Service) = | ||
discard status_general.startMessenger() | ||
|
||
proc newService*(): Service = | ||
result = Service() | ||
proc logout*(self: Service) = | ||
discard status_general.logout() | ||
|
||
proc init*(self: Service) = | ||
if not existsDir(app_constants.ROOTKEYSTOREDIR): | ||
createDir(app_constants.ROOTKEYSTOREDIR) | ||
proc getPasswordStrengthScore*(self: Service, password, userName: string): int = | ||
try: | ||
let response = status_general.getPasswordStrengthScore(password, @[userName]) | ||
if(response.result.contains("error")): | ||
let errMsg = response.result["error"].getStr() | ||
error "error: ", methodName="getPasswordStrengthScore", errDesription = errMsg | ||
return | ||
|
||
proc startMessenger*(self: Service) = | ||
discard status_general.startMessenger() | ||
return response.result["score"].getInt() | ||
except Exception as e: | ||
error "error: ", methodName="getPasswordStrengthScore", errName = e.name, errDesription = e.msg | ||
|
||
proc logout*(self: Service) = | ||
discard status_general.logout() | ||
proc generateImages*(self: Service, image: string, aX: int, aY: int, bX: int, bY: int): seq[Image] = | ||
try: | ||
let response = status_general.generateImages(image, aX, aY, bX, bY) | ||
if(response.result.kind != JArray): | ||
error "error: ", procName="generateImages", errDesription = "response is not an array" | ||
return | ||
|
||
proc getPasswordStrengthScore*(self: Service, password, userName: string): int = | ||
try: | ||
let response = status_general.getPasswordStrengthScore(password, @[userName]) | ||
if(response.result.contains("error")): | ||
let errMsg = response.result["error"].getStr() | ||
error "error: ", methodName="getPasswordStrengthScore", errDesription = errMsg | ||
return | ||
for img in response.result: | ||
result.add(toImage(img)) | ||
except Exception as e: | ||
error "error: ", procName="generateImages", errName = e.name, errDesription = e.msg | ||
|
||
return response.result["score"].getInt() | ||
except Exception as e: | ||
error "error: ", methodName="getPasswordStrengthScore", errName = e.name, errDesription = e.msg | ||
proc runTimer(self: Service) = | ||
let arg = TimerTaskArg( | ||
tptr: cast[ByteAddress](timerTask), | ||
vptr: cast[ByteAddress](self.vptr), | ||
slot: "onTimeout", | ||
timeoutInMilliseconds: TimerIntervalInMilliseconds | ||
) | ||
self.threadpool.start(arg) | ||
|
||
proc generateImages*(self: Service, image: string, aX: int, aY: int, bX: int, bY: int): seq[Image] = | ||
try: | ||
let response = status_general.generateImages(image, aX, aY, bX, bY) | ||
if(response.result.kind != JArray): | ||
error "error: ", procName="generateImages", errDesription = "response is not an array" | ||
return | ||
proc runTimer*(self: Service, timeoutInMilliseconds: int) = | ||
## Runs timer only once. Each 1000ms we check for timeout in order to have non blocking app closing. | ||
self.timeoutInMilliseconds = timeoutInMilliseconds | ||
self.runTimer() | ||
|
||
for img in response.result: | ||
result.add(toImage(img)) | ||
except Exception as e: | ||
error "error: ", procName="generateImages", errName = e.name, errDesription = e.msg | ||
proc onTimeout(self: Service, response: string) {.slot.} = | ||
self.timeoutInMilliseconds = self.timeoutInMilliseconds - TimerIntervalInMilliseconds | ||
if self.timeoutInMilliseconds <= 0: | ||
self.events.emit(SIGNAL_GENERAL_TIMEOUT, Args()) | ||
else: | ||
self.runTimer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters