fix(@desktop/general): Fix application not reponding on close
Changing timer interval to smaller value in order to close it correctly on shutdown. Issue #5938
This commit is contained in:
parent
65d90cbc51
commit
0cb3de69f3
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, json, sequtils, sugar, chronicles, strformat, stint, httpclient, net, strutils, os
|
||||
import NimQml, Tables, json, sequtils, sugar, chronicles, strformat, stint, httpclient, net, strutils, os, times
|
||||
import web3/[ethtypes, conversions]
|
||||
|
||||
import ../settings/service as settings_service
|
||||
|
@ -78,7 +78,8 @@ type DerivedAddressesArgs* = ref object of Args
|
|||
type TokensPerAccountArgs* = ref object of Args
|
||||
accountsTokens*: OrderedTable[string, seq[WalletTokenDto]] # [wallet address, list of tokens]
|
||||
|
||||
const CheckBalanceIntervalInMilliseconds = 15 * 60 * 1000 # 15 mins
|
||||
const CheckBalanceSlotExecuteIntervalInSeconds = 15 * 60 # 15 mins
|
||||
const CheckBalanceTimerIntervalInMilliseconds = 5000 # 5 sec
|
||||
|
||||
include async_tasks
|
||||
include ../../common/json_utils
|
||||
|
@ -94,11 +95,12 @@ QtObject:
|
|||
tokenService: token_service.Service
|
||||
networkService: network_service.Service
|
||||
walletAccounts: OrderedTable[string, WalletAccountDto]
|
||||
|
||||
timerStartTimeInSeconds: int64
|
||||
priceCache: TimedCache
|
||||
|
||||
# Forward declaration
|
||||
proc buildAllTokens(self: Service, calledFromTimerOrInit = false)
|
||||
proc startBuildingTokensTimer(self: Service, resetTimeToNow = true)
|
||||
|
||||
proc delete*(self: Service) =
|
||||
self.closingApp = true
|
||||
|
@ -337,21 +339,28 @@ QtObject:
|
|||
))
|
||||
|
||||
proc onStartBuildingTokensTimer*(self: Service, response: string) {.slot.} =
|
||||
if ((now().toTime().toUnix() - self.timerStartTimeInSeconds) < CheckBalanceSlotExecuteIntervalInSeconds):
|
||||
self.startBuildingTokensTimer(resetTimeToNow = false)
|
||||
return
|
||||
|
||||
if self.ignoreTimeInitiatedTokensBuild:
|
||||
self.ignoreTimeInitiatedTokensBuild = false
|
||||
return
|
||||
|
||||
self.buildAllTokens(true)
|
||||
|
||||
proc startBuildingTokensTimer(self: Service) =
|
||||
proc startBuildingTokensTimer(self: Service, resetTimeToNow = true) =
|
||||
if(self.closingApp):
|
||||
return
|
||||
|
||||
if (resetTimeToNow):
|
||||
self.timerStartTimeInSeconds = now().toTime().toUnix()
|
||||
|
||||
let arg = TimerTaskArg(
|
||||
tptr: cast[ByteAddress](timerTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "onStartBuildingTokensTimer",
|
||||
timeoutInMilliseconds: CheckBalanceIntervalInMilliseconds
|
||||
timeoutInMilliseconds: CheckBalanceTimerIntervalInMilliseconds
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
|
|
Loading…
Reference in New Issue