Skip to content

fix: keep the active search filter after deleting a track#448

Closed
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-85
Closed

fix: keep the active search filter after deleting a track#448
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-85

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Type of change(s)

  • Bug fix

What changed and why

When you search on the Tracks tab and then delete one of the matching tracks, the visible list would reset to the entire library instead of staying filtered.

Deleting a selected track posts Events.RefreshFragments(). MainActivity.shouldRefreshFragments() then calls refreshAllFragments(), which re-runs TracksFragment.setupFragment(). That method reloads the full library on a background thread and, back on the UI thread, calls updateItems(tracks) with the complete, unfiltered list and an empty highlight string. The search bar itself stays open (the query is still held by MySearchMenu), but the fragment never re-applies it, so the user is shown the whole library again.

The fix tracks the active query in a new lastSearchQuery field (set in onSearchQueryChanged, cleared in onSearchClosed) and, after the async reload finishes and the adapter is updated, re-applies the filter by calling onSearchQueryChanged(lastSearchQuery) when a query is still active. The filtered view (minus the deleted track) is now preserved.

Tests performed

  • detekt, lint, unit tests and the build all pass locally (CI-equivalent).
  • Source-verified: the tracks list now remembers the active search query and re-applies it after a refresh (e.g. following a delete), so search results are no longer replaced by the full library.
  • Note: verified via CI + code review; the search-then-delete UI flow was not scripted end-to-end.

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (verified via CI + source review; see Tests performed).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Coded with Opus 4.8 ultracode.

Deleting a selected track posts Events.RefreshFragments(), which makes MainActivity call refreshAllFragments() -> TracksFragment.setupFragment(). setupFragment reloads the full library asynchronously and calls updateItems() with the complete, unfiltered list, without re-applying the still-active search query. The search bar stays open but the list resets to the whole library.

Track the active query in lastSearchQuery and re-apply it via onSearchQueryChanged() after the async reload finishes, so the filtered view (minus the deleted track) is preserved. Clear it in onSearchClosed().

Closes FossifyOrg#85
@MiMoHo MiMoHo requested a review from naveensingh as a code owner July 3, 2026 21:44
@MiMoHo MiMoHo closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search feature not working correctly if you delete a file that you served for

1 participant