qml: use dirty flag on qetransactionlistmodel
This commit is contained in:
@@ -248,7 +248,7 @@ Pane {
|
|||||||
dialog.yesClicked.connect(function() {
|
dialog.yesClicked.connect(function() {
|
||||||
channeldetails.deleteChannel()
|
channeldetails.deleteChannel()
|
||||||
app.stack.pop()
|
app.stack.pop()
|
||||||
Daemon.currentWallet.historyModel.init_model() // needed here?
|
Daemon.currentWallet.historyModel.init_model(true) // needed here?
|
||||||
Daemon.currentWallet.channelModel.remove_channel(channelid)
|
Daemon.currentWallet.channelModel.remove_channel(channelid)
|
||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ ElDialog {
|
|||||||
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
|
+ qsTr('This channel will be usable after %1 confirmations').arg(min_depth)
|
||||||
if (!tx_complete) {
|
if (!tx_complete) {
|
||||||
message = message + '\n\n' + qsTr('Please sign and broadcast the funding transaction.')
|
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.state = 'success'
|
||||||
app.channelOpenProgressDialog.info = message
|
app.channelOpenProgressDialog.info = message
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ Pane {
|
|||||||
dialog.yesClicked.connect(function() {
|
dialog.yesClicked.connect(function() {
|
||||||
dialog.close()
|
dialog.close()
|
||||||
txdetails.removeLocalTx(true)
|
txdetails.removeLocalTx(true)
|
||||||
txdetails.wallet.historyModel.init_model()
|
txdetails.wallet.historyModel.init_model(true)
|
||||||
root.close()
|
root.close()
|
||||||
})
|
})
|
||||||
dialog.open()
|
dialog.open()
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
|||||||
self.destroyed.connect(lambda: self.on_destroy())
|
self.destroyed.connect(lambda: self.on_destroy())
|
||||||
self.requestRefresh.connect(lambda: self.init_model())
|
self.requestRefresh.connect(lambda: self.init_model())
|
||||||
|
|
||||||
|
self.setDirty()
|
||||||
self.init_model()
|
self.init_model()
|
||||||
|
|
||||||
def on_destroy(self):
|
def on_destroy(self):
|
||||||
@@ -71,6 +72,10 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
|||||||
return value.value
|
return value.value
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def setDirty(self):
|
||||||
|
self._dirty = True
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
self.tx_history = []
|
self.tx_history = []
|
||||||
@@ -139,7 +144,12 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
|||||||
|
|
||||||
# initial model data
|
# initial model data
|
||||||
@pyqtSlot()
|
@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')
|
self._logger.debug('retrieving history')
|
||||||
history = self.wallet.get_full_history(onchain_domain=self.onchain_domain,
|
history = self.wallet.get_full_history(onchain_domain=self.onchain_domain,
|
||||||
include_lightning=self.include_lightning)
|
include_lightning=self.include_lightning)
|
||||||
@@ -155,6 +165,8 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
|
|||||||
|
|
||||||
self.countChanged.emit()
|
self.countChanged.emit()
|
||||||
|
|
||||||
|
self._dirty = False
|
||||||
|
|
||||||
def on_tx_verified(self, txid, info):
|
def on_tx_verified(self, txid, info):
|
||||||
i = 0
|
i = 0
|
||||||
for tx in self.tx_history:
|
for tx in self.tx_history:
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
self._isUpToDate = uptodate
|
self._isUpToDate = uptodate
|
||||||
self.isUptodateChanged.emit()
|
self.isUptodateChanged.emit()
|
||||||
|
|
||||||
|
if uptodate:
|
||||||
|
self.historyModel.init_model()
|
||||||
|
|
||||||
if self.wallet.network.is_connected():
|
if self.wallet.network.is_connected():
|
||||||
server_height = self.wallet.network.get_server_height()
|
server_height = self.wallet.network.get_server_height()
|
||||||
server_lag = self.wallet.network.get_local_height() - 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._logger.info(f'new transaction {tx.txid()}')
|
||||||
self.add_tx_notification(tx)
|
self.add_tx_notification(tx)
|
||||||
self.addressModel.setDirty()
|
self.addressModel.setDirty()
|
||||||
self.historyModel.init_model() # TODO: be less dramatic
|
self.historyModel.setDirty() # assuming wallet.is_up_to_date triggers after
|
||||||
|
|
||||||
@event_listener
|
@event_listener
|
||||||
def on_event_wallet_updated(self, wallet):
|
def on_event_wallet_updated(self, wallet):
|
||||||
|
|||||||
Reference in New Issue
Block a user