Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run history_list_filter hook on updated labels #1990

Merged
merged 4 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions gui/qt/history_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self, parent):
self.withdrawalBrush = QBrush(QColor("#BC1E1E"))
self.invoiceIcon = QIcon(":icons/seal")
self._item_cache = Weak.ValueDictionary()
self.itemChanged.connect(self.item_changed)

self.has_unknown_balances = False

Expand Down Expand Up @@ -187,8 +188,22 @@ def update_labels(self):
for i in range(child_count):
item = root.child(i)
txid = item.data(0, Qt.UserRole)
label = self.wallet.get_label(txid)
item.setText(3, label)
h_label = self.wallet.get_label(txid)
current_label = item.text(3)
item.setText(3, h_label)
if current_label != h_label:
self.item_changed(item, 3)

def item_changed(self, item, column):
# Run the label of the changed item thru the filter hook
if column != 3:
return

label = item.text(3)
# NB: 'h_item' parameter is None due to performance reasons
should_skip = run_hook("history_list_filter", self, None, label, multi=True) or []
if any(should_skip):
item.setHidden(True)

def update_item(self, tx_hash, height, conf, timestamp):
if not self.wallet: return # can happen on startup if this is called before self.on_update()
Expand Down
1 change: 1 addition & 0 deletions plugins/fusion/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def on_status(controller):

@hook
def history_list_filter(self, history_list, h_item, label):
# NB: 'h_item' might be None due to performance reasons
if self._hide_history_txs:
return bool(label.startswith("CashFusion ")) # this string is not translated for performance reasons
return None
Expand Down
1 change: 1 addition & 0 deletions plugins/shuffle_deprecated/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ def utxo_list_context_menu_setup(self, utxo_list, menu, selected):

@hook
def history_list_filter(self, history_list, h_item, label):
# NB: 'h_item' might be None due to performance reasons
if self._hide_history_txs:
return bool(label.startswith("Shuffle ") # this string is not translated for performance reasons. _make_label also does not translate this string.
and ( any( x for x in BackgroundShufflingThread.SCALE_ARROWS
Expand Down