From 0ec4b989c9bbe6f103219c71523ce78fa0e0161b Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Tue, 19 May 2026 12:50:09 +0100 Subject: [PATCH] ML-169.5: add display toggle performance fix task --- ...oggle-grid-list-triggers-full-DB-reload.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 backlog/tasks/ml-169.5 - Fix-Display-toggle-grid-list-triggers-full-DB-reload.md diff --git a/backlog/tasks/ml-169.5 - Fix-Display-toggle-grid-list-triggers-full-DB-reload.md b/backlog/tasks/ml-169.5 - Fix-Display-toggle-grid-list-triggers-full-DB-reload.md new file mode 100644 index 00000000..7a8c6704 --- /dev/null +++ b/backlog/tasks/ml-169.5 - Fix-Display-toggle-grid-list-triggers-full-DB-reload.md @@ -0,0 +1,58 @@ +--- +id: ML-169.5 +title: "Fix: Display toggle (grid/list) triggers full DB reload" +status: To Do +assignee: [] +created_date: "2026-05-19 11:45" +labels: + - perf + - fix +dependencies: [] +references: + - >- + backlog/documents/doc-27 - + Phase-4-Performance-Audit-Low-Hanging-Fruit-Findings.md +modified_files: + - lib/music_library_web/live_helpers/index_actions.ex + - lib/music_library_web/live/collection_live/index.ex + - lib/music_library_web/live/wishlist_live/index.ex +parent_task_id: ML-169 +priority: high +ordinal: 26000 +--- + +## Description + + + +Fix performance issue where toggling between grid and list display views triggers a full FTS database reload. + +## Problem + +`handle_set_display` in `index_actions.ex` calls `load_and_assign_records/2` which re-executes the full FTS search query (`search_records_count` + `search_records`). The toggle only changes a CSS layout class (`@display == :grid` vs `@display == :list`) — no data changes. + +## Impact + +Every grid/list toggle wastes 2 FTS queries. This is a common user interaction (clicking the view switcher button). + +## Files + +- `lib/music_library_web/live_helpers/index_actions.ex:136-143` — `handle_set_display/2` calls `load_and_assign_records` +- `lib/music_library_web/live/collection_live/index.ex:336` — `handle_event("set_display")` +- `lib/music_library_web/live/wishlist_live/index.ex:259` — `handle_event("set_display")` + +## Fix + +Remove the `load_and_assign_records` call from `handle_set_display`. Only `assign(:display, mode)` is needed. The existing `:if={@display == :grid}` / `:if={@display == :list}` conditionals already handle showing/hiding the appropriate view. + + + +## Acceptance Criteria + + + +- [ ] #1 Grid/list toggle no longer triggers DB queries (verified via QueryReporter) +- [ ] #2 Grid view renders correctly after toggle +- [ ] #3 List view renders correctly after toggle +- [ ] #4 No regression in search/filter functionality after toggle +