fix(wallet) counterparty loading forever in activity history
Closes: #14067
This commit is contained in:
parent
17d078b33e
commit
fb530a099a
|
@ -471,6 +471,7 @@ QtObject:
|
|||
|
||||
proc updateRecipientsModel*(self: Controller) {.slot.} =
|
||||
self.status.setLoadingRecipients(true)
|
||||
# Recipients don't change with filers so we can use the same request id
|
||||
let res = backend_activity.getRecipientsAsync(self.sessionId(), self.chainIds, self.addresses, 0, FETCH_RECIPIENTS_BATCH_COUNT_DEFAULT)
|
||||
if res.error != nil or res.result.kind != JBool:
|
||||
self.status.setLoadingRecipients(false)
|
||||
|
@ -483,6 +484,7 @@ QtObject:
|
|||
|
||||
proc loadMoreRecipients(self: Controller) {.slot.} =
|
||||
self.status.setLoadingRecipients(true)
|
||||
# Recipients don't change with filers so we can use the same request id
|
||||
let res = backend_activity.getRecipientsAsync(self.sessionId(), self.chainIds, self.addresses, self.recipientsModel.getCount(), FETCH_RECIPIENTS_BATCH_COUNT_DEFAULT)
|
||||
if res.error != nil:
|
||||
self.status.setLoadingRecipients(false)
|
||||
|
|
|
@ -48,7 +48,12 @@ QtObject:
|
|||
proc handleApiEvents(self: EventsHandler, e: Args) =
|
||||
var data = WalletSignal(e)
|
||||
|
||||
if not data.requestId.isSome() or not self.sessionId.isSome() or data.requestId.get() != self.sessionId.get():
|
||||
# All activiy messages have a requestId matching the session ID or static request ID
|
||||
if not data.requestId.isSome():
|
||||
return
|
||||
|
||||
# Ignore message requested by other sessions
|
||||
if self.sessionId.isSome() and data.requestId.get() != self.sessionId.get():
|
||||
return
|
||||
|
||||
if self.walletEventHandlers.hasKey(data.eventType):
|
||||
|
@ -74,7 +79,7 @@ QtObject:
|
|||
)
|
||||
|
||||
proc getSessionId*(self: EventsHandler): int32 =
|
||||
self.sessionId.get(-1)
|
||||
return self.sessionId.get(-1)
|
||||
|
||||
proc setSessionId*(self: EventsHandler, sessionId: int32) =
|
||||
self.sessionId = some(sessionId)
|
||||
|
|
|
@ -12,9 +12,10 @@ QtObject:
|
|||
loadingData: bool
|
||||
errorCode: backend_activity.ErrorCode
|
||||
|
||||
loadingRecipients: Atomic[int]
|
||||
loadingCollectibles: Atomic[int]
|
||||
loadingStartTimestamp: Atomic[int]
|
||||
# No need for synchronization primitives, all operations are serialized on the main thread; see events_handler.nim
|
||||
loadingRecipients: bool
|
||||
loadingStartTimestamp: bool
|
||||
|
||||
startTimestamp: int
|
||||
|
||||
|
@ -42,8 +43,9 @@ QtObject:
|
|||
proc loadingRecipientsChanged*(self: Status) {.signal.}
|
||||
|
||||
proc setLoadingRecipients*(self: Status, loadingData: bool) =
|
||||
discard fetchAdd(self.loadingRecipients, if loadingData: 1 else: -1)
|
||||
self.loadingRecipientsChanged()
|
||||
if self.loadingRecipients != loadingData:
|
||||
self.loadingRecipients = loadingData
|
||||
self.loadingRecipientsChanged()
|
||||
|
||||
proc loadingCollectiblesChanged*(self: Status) {.signal.}
|
||||
|
||||
|
@ -54,8 +56,9 @@ QtObject:
|
|||
proc loadingStartTimestampChanged*(self: Status) {.signal.}
|
||||
|
||||
proc setLoadingStartTimestamp*(self: Status, loadingData: bool) =
|
||||
discard fetchAdd(self.loadingStartTimestamp, if loadingData: 1 else: -1)
|
||||
self.loadingStartTimestampChanged()
|
||||
if self.loadingStartTimestamp != loadingData:
|
||||
self.loadingStartTimestamp = loadingData
|
||||
self.loadingStartTimestampChanged()
|
||||
|
||||
proc errorCodeChanged*(self: Status) {.signal.}
|
||||
|
||||
|
@ -86,14 +89,14 @@ QtObject:
|
|||
notify = errorCodeChanged
|
||||
|
||||
proc getLoadingRecipients*(self: Status): bool {.slot.} =
|
||||
return load(self.loadingRecipients) > 0
|
||||
return self.loadingRecipients
|
||||
|
||||
QtProperty[bool] loadingRecipients:
|
||||
read = getLoadingRecipients
|
||||
notify = loadingRecipientsChanged
|
||||
|
||||
proc getLoadingStartTimestamp*(self: Status): bool {.slot.} =
|
||||
return load(self.loadingStartTimestamp) > 0
|
||||
return self.loadingStartTimestamp
|
||||
|
||||
QtProperty[bool] loadingStartTimestamp:
|
||||
read = getLoadingStartTimestamp
|
||||
|
|
Loading…
Reference in New Issue