Skip to content

Commit 72bedbd

Browse files
wesmclaude
andcommitted
fix: Pressing 'h' twice now reverts hide toggle instead of double-toggling
Fixed buggy behavior where pressing 'h' twice on the same transaction would add two conflicting hide/unhide edits to pending changes. Now: - First 'h': Queues hide/unhide toggle - Second 'h': Removes the pending edit (reverts the change) This gives users a natural undo mechanism for accidental hide toggles. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e61e679 commit 72bedbd

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

moneyflow/app.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,17 +1281,30 @@ def action_toggle_hide_from_reports(self) -> None:
12811281
# Toggle single transaction
12821282
row_data = self.state.current_data.row(table.cursor_row, named=True)
12831283
txn_id = row_data["id"]
1284-
current_hidden = row_data.get("hideFromReports", False)
1284+
1285+
# Check if there's already a pending hide toggle for this transaction
1286+
existing_edit = None
1287+
for edit in self.data_manager.pending_edits:
1288+
if edit.transaction_id == txn_id and edit.field == "hide_from_reports":
1289+
existing_edit = edit
1290+
break
12851291

12861292
# Save cursor position before refresh
12871293
saved_cursor_row = table.cursor_row
12881294

1289-
# Use controller helper for consistency
1290-
single_txn = self.state.current_data.filter(pl.col("id") == txn_id)
1291-
self.controller.queue_hide_toggle_edits(single_txn)
1295+
if existing_edit:
1296+
# Remove the pending edit (undo the toggle)
1297+
self.data_manager.pending_edits.remove(existing_edit)
1298+
self.notify("Reverted hide/unhide change", timeout=2)
1299+
else:
1300+
# Queue a new toggle edit
1301+
current_hidden = row_data.get("hideFromReports", False)
1302+
single_txn = self.state.current_data.filter(pl.col("id") == txn_id)
1303+
self.controller.queue_hide_toggle_edits(single_txn)
1304+
1305+
action = "Unhidden" if current_hidden else "Hidden"
1306+
self.notify(f"{action} from reports. Press w to commit.", timeout=2)
12921307

1293-
action = "Unhidden" if current_hidden else "Hidden"
1294-
self.notify(f"{action} from reports. Press w to commit.", timeout=2)
12951308
self.refresh_view()
12961309
# Restore cursor position
12971310
if saved_cursor_row < table.row_count:

moneyflow/data_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"Fast Food",
4747
"Food & Drink",
4848
"Alcohol",
49+
"Quick Eats"
4950
],
5051
"Travel": [
5152
"Airfare",

0 commit comments

Comments
 (0)