diff --git a/src/sakia/gui/navigation/txhistory/controller.py b/src/sakia/gui/navigation/txhistory/controller.py index 12fa806058f0e08894941ec92578de8e3a71bf72..f30362b0081129c8d62f9ef2616684b08d771782 100644 --- a/src/sakia/gui/navigation/txhistory/controller.py +++ b/src/sakia/gui/navigation/txhistory/controller.py @@ -186,31 +186,43 @@ class TxHistoryController(QObject): Update tx history from network for the selected date period :return: """ - self._logger.debug("Manually refresh tx history...") + self._logger.debug("Manually update tx history...") - pubkey = self.model.connection.pubkey - - ( - changed_tx, - new_tx, - ) = await self.model.transactions_service.update_transactions_history( - pubkey, - self.view.table_history.model().ts_from, - self.view.table_history.model().ts_to, - ) - for tx in changed_tx: - self.model.app.transaction_state_changed.emit(tx) + # disable update button + self.view.button_refresh.setDisabled(True) - for tx in new_tx: - self.model.app.new_transfer.emit(self.model.connection, tx) + pubkey = self.model.connection.pubkey + try: + ( + changed_tx, + new_tx, + ) = await self.model.transactions_service.update_transactions_history( + pubkey, + self.view.table_history.model().ts_from, + self.view.table_history.model().ts_to, + ) + for tx in changed_tx: + self.model.app.transaction_state_changed.emit(tx) + + for tx in new_tx: + self.model.app.new_transfer.emit(self.model.connection, tx) + except Exception as e: + self._logger.error(str(e)) + + try: + new_dividends = await self.model.transactions_service.update_dividends_history( + pubkey, + self.view.table_history.model().ts_from, + self.view.table_history.model().ts_to, + new_tx, + ) + self._logger.debug("Found {} new dividends".format(len(new_dividends))) - new_dividends = await self.model.transactions_service.update_dividends_history( - pubkey, - self.view.table_history.model().ts_from, - self.view.table_history.model().ts_to, - new_tx, - ) - self._logger.debug("Found {} new dividends".format(len(new_dividends))) + for ud in new_dividends: + self.model.app.new_dividend.emit(self.model.connection, ud) + except Exception as e: + self._logger.error(str(e)) - for ud in new_dividends: - self.model.app.new_dividend.emit(self.model.connection, ud) + # enable update button + self.view.button_refresh.setDisabled(False) + self._logger.debug("Manually update tx history finished")