Fetch games on search view mount and reset search state on input clear#3080
Fetch games on search view mount and reset search state on input clear#3080
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the gallery search flow so the Search view initiates a ROM fetch on mount, and clearing the search input triggers a search reset/update.
Changes:
- Trigger an initial ROM fetch when
Gallery/Search.vuemounts. - When clearing the search input, reset related search state and emit a
filterRomsevent to refresh results.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
frontend/src/views/Gallery/Search.vue |
Fetch ROMs on mount (currently uses await fetchRoms() in the mounted hook). |
frontend/src/components/Gallery/AppBar/Search/SearchTextField.vue |
On clear, resets searchTerm, sets initialSearch, and emits filterRoms to refresh the gallery. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| onMounted(async () => { | ||
| scrolledToTop.value = true; | ||
| await fetchRoms(); | ||
| }); |
There was a problem hiding this comment.
await fetchRoms() doesn't currently await the underlying request because fetchRoms() doesn't return the romsStore.fetchRoms() Promise (it returns void after attaching a .catch). Either remove the await here, or refactor fetchRoms() to return/await romsStore.fetchRoms() so callers (mounted hook, infinite scroll, LoadMoreBtn) can reliably wait for completion and handle errors consistently.
|
|
||
| function clearInput() { | ||
| searchTerm.value = null; | ||
| initialSearch.value = true; |
There was a problem hiding this comment.
clearInput() sets initialSearch.value = true, but Search.vue uses initialSearch to choose between the pre-search prompt (<EmptySearch /> when !initialSearch) and the post-search empty-results state (<EmptyGame /> when initialSearch). With this change, clearing the input will keep the UI in the post-search state; if the goal is to reset the search state on clear, initialSearch should likely be set back to false here.
| initialSearch.value = true; | |
| initialSearch.value = false; |
Greptile SummaryThis PR makes two focused improvements to the Search gallery view: it triggers Key changes:
Confidence Score: 5/5
Sequence DiagramsequenceDiagram
participant User
participant Search.vue
participant SearchTextField.vue
participant FilterDrawer
participant romsStore
Note over Search.vue, SearchTextField.vue: View Mount
SearchTextField.vue->>romsStore: reset() [child onMounted first]
Search.vue->>romsStore: fetchRoms() [parent onMounted after]
romsStore-->>Search.vue: roms loaded
Note over User, romsStore: User types in search box
User->>SearchTextField.vue: keyup.enter / model-value update
SearchTextField.vue->>SearchTextField.vue: fetchRoms() — sets initialSearch=true
SearchTextField.vue->>FilterDrawer: emit("filterRoms", null)
FilterDrawer->>romsStore: resetPagination() + fetchRoms(false)
romsStore-->>Search.vue: filtered roms loaded
Note over User, romsStore: User clears the input
User->>SearchTextField.vue: click:clear → clearInput()
SearchTextField.vue->>SearchTextField.vue: searchTerm=null, initialSearch=false
SearchTextField.vue->>FilterDrawer: emit("filterRoms", null)
FilterDrawer->>romsStore: resetPagination() + fetchRoms(false)
romsStore-->>Search.vue: all roms (no filter) loaded
Last reviewed commit: ea2532f |
Description
Explain the changes or enhancements you are proposing with this pull request.
Trigger fetchRoms on search view mount and reset search state on input clear
Checklist
Please check all that apply.
Screenshots (if applicable)