Skip to content

feat: persist the selected category in the URL - #2102

Open
tahodev wants to merge 1 commit into
nextcloud:mainfrom
tahodev:feat/persist-selected-category
Open

tahodev wants to merge 1 commit into
nextcloud:mainfrom
tahodev:feat/persist-selected-category

Conversation

@tahodev

@tahodev tahodev commented Oct 23, 2026

Copy link
Copy Markdown

What

Implements #2033: the selected category is now persisted across page loads.

The category filter lived only in the pinia store, so every reload reset the list to "All notes". The store selection is now mirrored into the category query parameter and restored once when the app loads, before the default note routing runs.

How

  • src/Util.js: new queryWithCategory(query, category) helper. It returns the query with the category applied/removed, or null when unchanged, so the caller never triggers a redundant router.replace.
  • src/App.vue: watchers on the store selection and on $route re-apply the parameter after every navigation (route pushes in the app do not carry query params), and loadNotes() restores the selection from the URL before routeDefault(), so the first-open note is picked from the filtered list.

One-way by design (store -> URL; URL -> store only at load): this keeps every existing router.push untouched and avoids loops between the URL and the store. Back/forward does not change the filter; reloading does, which is the behavior requested in the issue.

A category in the URL that no longer exists simply yields an empty list with a working "All notes" escape, the same as selecting such a category in the UI.

Tests

  • 8 new unit tests for queryWithCategory in src/tests/Util.spec.js (add/keep params/nested names/no-op/replace/clear/no mutation).
  • npx vitest run: 95 passed (4 files). npx eslint src/: 0 errors (3 pre-existing warnings). webpack --node-env production builds clean.
  • Not run locally: the Playwright e2e suite (needs a Nextcloud server); CI covers it.

Resolves #2033


AI assistance (various models) was used in preparing this change.

The selected category was only kept in memory, so a page reload reset
the notes list to 'All notes'. It is now mirrored to the 'category'
query parameter (one-way, store -> URL, re-applied after every
navigation since route pushes drop query params) and restored from the
URL once when the app loads.

Signed-off-by: tahodev <85001874+tahodev@users.noreply.github.com>
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.

The selected category is not persisted across page loads

1 participant