diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index 6dba0e740..2ba369398 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -248,7 +248,7 @@ Pane { dialog.yesClicked.connect(function() { channeldetails.deleteChannel() app.stack.pop() - Daemon.currentWallet.historyModel.init_model() // needed here? + Daemon.currentWallet.historyModel.init_model(true) // needed here? Daemon.currentWallet.channelModel.remove_channel(channelid) }) dialog.open() diff --git a/electrum/gui/qml/components/OpenChannelDialog.qml b/electrum/gui/qml/components/OpenChannelDialog.qml index 44545c04f..642e98ca6 100644 --- a/electrum/gui/qml/components/OpenChannelDialog.qml +++ b/electrum/gui/qml/components/OpenChannelDialog.qml @@ -227,7 +227,7 @@ ElDialog { + qsTr('This channel will be usable after %1 confirmations').arg(min_depth) if (!tx_complete) { message = message + '\n\n' + qsTr('Please sign and broadcast the funding transaction.') - channelopener.wallet.historyModel.init_model() // local tx doesn't trigger model update + channelopener.wallet.historyModel.init_model(true) // local tx doesn't trigger model update } app.channelOpenProgressDialog.state = 'success' app.channelOpenProgressDialog.info = message diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index ae220e179..06c6602b3 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/electrum/gui/qml/components/TxDetails.qml @@ -384,7 +384,7 @@ Pane { dialog.yesClicked.connect(function() { dialog.close() txdetails.removeLocalTx(true) - txdetails.wallet.historyModel.init_model() + txdetails.wallet.historyModel.init_model(true) root.close() }) dialog.open() diff --git a/electrum/gui/qml/qetransactionlistmodel.py b/electrum/gui/qml/qetransactionlistmodel.py index 478a7b8c1..33f2f4bde 100644 --- a/electrum/gui/qml/qetransactionlistmodel.py +++ b/electrum/gui/qml/qetransactionlistmodel.py @@ -32,6 +32,7 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): self.destroyed.connect(lambda: self.on_destroy()) self.requestRefresh.connect(lambda: self.init_model()) + self.setDirty() self.init_model() def on_destroy(self): @@ -71,6 +72,10 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): return value.value return str(value) + @pyqtSlot() + def setDirty(self): + self._dirty = True + def clear(self): self.beginResetModel() self.tx_history = [] @@ -139,7 +144,12 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): # initial model data @pyqtSlot() - def init_model(self): + @pyqtSlot(bool) + def init_model(self, force: bool = False): + # only (re)construct if dirty or forced + if not self._dirty and not force: + return + self._logger.debug('retrieving history') history = self.wallet.get_full_history(onchain_domain=self.onchain_domain, include_lightning=self.include_lightning) @@ -155,6 +165,8 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): self.countChanged.emit() + self._dirty = False + def on_tx_verified(self, txid, info): i = 0 for tx in self.tx_history: diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 15871546a..06e874633 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -148,6 +148,9 @@ class QEWallet(AuthMixin, QObject, QtEventListener): self._isUpToDate = uptodate self.isUptodateChanged.emit() + if uptodate: + self.historyModel.init_model() + if self.wallet.network.is_connected(): server_height = self.wallet.network.get_server_height() server_lag = self.wallet.network.get_local_height() - server_height @@ -187,7 +190,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener): self._logger.info(f'new transaction {tx.txid()}') self.add_tx_notification(tx) self.addressModel.setDirty() - self.historyModel.init_model() # TODO: be less dramatic + self.historyModel.setDirty() # assuming wallet.is_up_to_date triggers after @event_listener def on_event_wallet_updated(self, wallet):