From 5fdab995f55c5b2286edb47555470b98c0b2080d Mon Sep 17 00:00:00 2001 From: gitgiggety <79809426+gitgiggety@users.noreply.github.com> Date: Sun, 26 Sep 2021 05:51:45 +0200 Subject: [PATCH] Fix list state navigation (#1765) * Fix sort direction being lost filtering scenes list Fix thevsort direction being lost on the scenes (& images & galleries?) lists when filtering the list by using the "badges" on the tags / performers / ... popovers. * Fix using back button not clearing filters to empty Fix (re)setting of a lists criterion based on the URL in case the new URL doesn't have criterions / "c" set. When it's unset it should be assumed the criterions must be empty, instead of maintaining the current criterions (which could be populated wirh the old criterions when the list was shown before). * Set page to 1 on list when applying new filter --- .../src/components/Changelog/versions/v0100.md | 2 ++ ui/v2.5/src/models/list-filter/filter.ts | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/v2.5/src/components/Changelog/versions/v0100.md b/ui/v2.5/src/components/Changelog/versions/v0100.md index 15cff6428..fe0ceaf8b 100644 --- a/ui/v2.5/src/components/Changelog/versions/v0100.md +++ b/ui/v2.5/src/components/Changelog/versions/v0100.md @@ -20,6 +20,8 @@ * Added sv-SE language option. ([#1691](https://github.com/stashapp/stash/pull/1691)) ### 🐛 Bug fixes +* Fix criteria being incorrectly applied when clicking back button. ([#1765](https://github.com/stashapp/stash/pull/1765)) +* Show first page and fix order direction not being maintained when clicking on card popover button. ([#1765](https://github.com/stashapp/stash/pull/1765)) * Fix panic in autotagger when backslash character present in tag/performer/studio name. ([#1753](https://github.com/stashapp/stash/pull/1753)) * Fix Scene Player CLS issue ([#1739](https://github.com/stashapp/stash/pull/1739)) * Fix Scene Edit Panel form layout for mobile and desktop. ([#1737](https://github.com/stashapp/stash/pull/1737)) diff --git a/ui/v2.5/src/models/list-filter/filter.ts b/ui/v2.5/src/models/list-filter/filter.ts index b59fcb57b..3e80d0fb9 100644 --- a/ui/v2.5/src/models/list-filter/filter.ts +++ b/ui/v2.5/src/models/list-filter/filter.ts @@ -79,19 +79,19 @@ export class ListFilterModel { } } } - this.sortDirection = - params.sortdir === "desc" - ? SortDirectionEnum.Desc - : SortDirectionEnum.Asc; + if (params.sortdir !== undefined) { + this.sortDirection = + params.sortdir === "desc" + ? SortDirectionEnum.Desc + : SortDirectionEnum.Asc; + } if (params.disp !== undefined) { this.displayMode = Number.parseInt(params.disp, 10); } if (params.q) { this.searchTerm = params.q.trim(); } - if (params.p) { - this.currentPage = Number.parseInt(params.p, 10); - } + this.currentPage = params.p ? Number.parseInt(params.p, 10) : 1; if (params.perPage) this.itemsPerPage = Number.parseInt(params.perPage, 10); if (params.z !== undefined) { const zoomIndex = Number.parseInt(params.z, 10); @@ -100,9 +100,8 @@ export class ListFilterModel { } } + this.criteria = []; if (params.c !== undefined) { - this.criteria = []; - let jsonParameters: string[]; if (params.c instanceof Array) { jsonParameters = params.c;