implement user notifications for new_transaction events
As the QML app can have multiple active wallets managed from
a single window (unlike the desktop Qt version), we let each
wallet manage its own user notification queue (as there are
some rules here specific to each wallet, e.g. not emitting
user notifications for each tx while the wallet is still
syncing), including collating and rate limiting. The app then
consumes the userNotify events from all active wallets, and
adds these to its own queue, which get displayed (eventually,
again implementing rate limiting) to the user.
It also uses timers efficiently, only enabling them if there
are actual userNotify events waiting.
If at any point the QML app wants to use multiple windows,
it can forego on the app user notification queue and instead
attach each window to the associated wallet userNotify signal.
app
▲
│
│ timer -> userNotify(msg) signal
│
┌──┬───┴───────┐
│ │ │ app user notification queue
└──┴───▲───────┘
│
│ timer -> userNotify(wallet, msg) signal
│
┌──┬───┴───────┐
│ │ │ wallet user notification queue
└──┴───▲───────┘
│
│ new_transaction
│
wallet
# Combine the transactions if there are at least three
iflen(txns)>=3:
total_amount=0
fortxintxns:
tx_wallet_delta=self.wallet.get_wallet_delta(tx)
ifnottx_wallet_delta.is_relevant:
continue
total_amount+=tx_wallet_delta.delta
self.userNotify.emit(self.wallet,_("{} new transactions: Total amount received in the new transactions {}").format(len(txns),config.format_amount_and_units(total_amount)))