Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
-3
@@ -271,14 +271,11 @@ export class BookBrowserQueryParamsService {
|
|||||||
|
|
||||||
syncQueryParams(
|
syncQueryParams(
|
||||||
viewMode: string,
|
viewMode: string,
|
||||||
sortCriteria: SortOption[],
|
|
||||||
filterMode: BookFilterMode,
|
filterMode: BookFilterMode,
|
||||||
filters: Record<string, string[]>
|
filters: Record<string, string[]>
|
||||||
): void {
|
): void {
|
||||||
const queryParams: Record<string, string | number | null | undefined> = {
|
const queryParams: Record<string, string | number | null | undefined> = {
|
||||||
[QUERY_PARAMS.VIEW]: viewMode,
|
[QUERY_PARAMS.VIEW]: viewMode,
|
||||||
[QUERY_PARAMS.SORT]: this.serializeSort(sortCriteria),
|
|
||||||
[QUERY_PARAMS.DIRECTION]: null, // Remove legacy direction param
|
|
||||||
[QUERY_PARAMS.FMODE]: filterMode,
|
[QUERY_PARAMS.FMODE]: filterMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -52,7 +52,7 @@ import {BookNavigationService} from '../../service/book-navigation.service';
|
|||||||
import {BookCardOverlayPreferenceService} from './book-card-overlay-preference.service';
|
import {BookCardOverlayPreferenceService} from './book-card-overlay-preference.service';
|
||||||
import {BookSelectionService, CheckboxClickEvent} from './book-selection.service';
|
import {BookSelectionService, CheckboxClickEvent} from './book-selection.service';
|
||||||
import {BookBrowserQueryParamsService, VIEW_MODES} from './book-browser-query-params.service';
|
import {BookBrowserQueryParamsService, VIEW_MODES} from './book-browser-query-params.service';
|
||||||
import {BookBrowserEntityService} from './book-browser-entity.service';
|
import {BookBrowserEntityService, EntityInfo} from './book-browser-entity.service';
|
||||||
import {BookFilterOrchestrationService} from './book-filter-orchestration.service';
|
import {BookFilterOrchestrationService} from './book-filter-orchestration.service';
|
||||||
import {BookBrowserScrollService} from './book-browser-scroll.service';
|
import {BookBrowserScrollService} from './book-browser-scroll.service';
|
||||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||||
@@ -127,6 +127,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
bookState$: Observable<BookState> | undefined;
|
bookState$: Observable<BookState> | undefined;
|
||||||
entity$: Observable<Library | Shelf | MagicShelf | null> | undefined;
|
entity$: Observable<Library | Shelf | MagicShelf | null> | undefined;
|
||||||
entityType$: Observable<EntityType> | undefined;
|
entityType$: Observable<EntityType> | undefined;
|
||||||
|
private entityRouteInfo$!: Observable<EntityInfo>;
|
||||||
searchTerm$ = new BehaviorSubject<string>('');
|
searchTerm$ = new BehaviorSubject<string>('');
|
||||||
selectedFilter = new BehaviorSubject<Record<string, string[]> | null>(null);
|
selectedFilter = new BehaviorSubject<Record<string, string[]> | null>(null);
|
||||||
selectedFilterMode = new BehaviorSubject<BookFilterMode>('and');
|
selectedFilterMode = new BehaviorSubject<BookFilterMode>('and');
|
||||||
@@ -349,11 +350,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const entityType = currentPath === 'all-books' ? EntityType.ALL_BOOKS : EntityType.UNSHELVED;
|
const entityType = currentPath === 'all-books' ? EntityType.ALL_BOOKS : EntityType.UNSHELVED;
|
||||||
this.entityType = entityType;
|
this.entityType = entityType;
|
||||||
this.entityType$ = of(entityType);
|
this.entityType$ = of(entityType);
|
||||||
|
this.entityRouteInfo$ = of({entityId: NaN, entityType});
|
||||||
this.entity$ = of(null);
|
this.entity$ = of(null);
|
||||||
this.seriesCollapseFilter.setContext(null, null);
|
this.seriesCollapseFilter.setContext(null, null);
|
||||||
this.pageTitle.setPageTitle(currentPath === 'all-books' ? this.t.translate('book.browser.labels.allBooks') : this.t.translate('book.browser.labels.unshelvedBooks'));
|
this.pageTitle.setPageTitle(currentPath === 'all-books' ? this.t.translate('book.browser.labels.allBooks') : this.t.translate('book.browser.labels.unshelvedBooks'));
|
||||||
} else {
|
} else {
|
||||||
const routeEntityInfo$ = this.entityService.getEntityInfoFromRoute(this.activatedRoute);
|
const routeEntityInfo$ = this.entityService.getEntityInfoFromRoute(this.activatedRoute);
|
||||||
|
this.entityRouteInfo$ = routeEntityInfo$;
|
||||||
this.entityType$ = routeEntityInfo$.pipe(map(info => {
|
this.entityType$ = routeEntityInfo$.pipe(map(info => {
|
||||||
this.entityType = info.entityType;
|
this.entityType = info.entityType;
|
||||||
return info.entityType;
|
return info.entityType;
|
||||||
@@ -408,15 +411,15 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
private setupQueryParamSubscription(): void {
|
private setupQueryParamSubscription(): void {
|
||||||
combineLatest([
|
combineLatest([
|
||||||
this.activatedRoute.paramMap,
|
this.entityRouteInfo$,
|
||||||
this.activatedRoute.queryParamMap,
|
this.activatedRoute.queryParamMap,
|
||||||
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
||||||
]).subscribe(([_, queryParamMap, user]) => {
|
]).subscribe(([entityInfo, queryParamMap, user]) => {
|
||||||
const parseResult = this.queryParamsService.parseQueryParams(
|
const parseResult = this.queryParamsService.parseQueryParams(
|
||||||
queryParamMap,
|
queryParamMap,
|
||||||
user.user?.userSettings?.entityViewPreferences,
|
user.user?.userSettings?.entityViewPreferences,
|
||||||
this.entityType,
|
entityInfo.entityType,
|
||||||
this.entity?.id ?? undefined,
|
entityInfo.entityId,
|
||||||
this.bookSorter.sortOptions,
|
this.bookSorter.sortOptions,
|
||||||
user.user?.userSettings?.filterMode ?? 'and'
|
user.user?.userSettings?.filterMode ?? 'and'
|
||||||
);
|
);
|
||||||
@@ -470,13 +473,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.visibleSortOptions = visibleFields.map(f => sortOptionsByField.get(f)).filter((o): o is SortOption => !!o);
|
this.visibleSortOptions = visibleFields.map(f => sortOptionsByField.get(f)).filter((o): o is SortOption => !!o);
|
||||||
|
|
||||||
|
|
||||||
// Only update sort criteria if they actually changed to avoid resetting popover/CDK state.
|
if (!this.areSortCriteriaEqual(this.bookSorter.selectedSortCriteria, parseResult.sortCriteria)) {
|
||||||
// Skip preference-based sort re-derivation when sort is already established (prevents
|
|
||||||
// userState$ emissions from non-sort preference changes like seriesCollapsed from
|
|
||||||
// resetting the sort during the race window before syncQueryParams writes to URL).
|
|
||||||
const sortFromUrl = !!queryParamMap.get('sort');
|
|
||||||
const sortNotYetEstablished = this.bookSorter.selectedSortCriteria.length === 0;
|
|
||||||
if ((sortFromUrl || sortNotYetEstablished) && !this.areSortCriteriaEqual(this.bookSorter.selectedSortCriteria, parseResult.sortCriteria)) {
|
|
||||||
this.bookSorter.setSortCriteria(parseResult.sortCriteria);
|
this.bookSorter.setSortCriteria(parseResult.sortCriteria);
|
||||||
}
|
}
|
||||||
this.currentViewMode = parseResult.viewMode;
|
this.currentViewMode = parseResult.viewMode;
|
||||||
@@ -489,7 +486,6 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
this.queryParamsService.syncQueryParams(
|
this.queryParamsService.syncQueryParams(
|
||||||
this.currentViewMode!,
|
this.currentViewMode!,
|
||||||
this.bookSorter.selectedSortCriteria,
|
|
||||||
this.selectedFilterMode.getValue(),
|
this.selectedFilterMode.getValue(),
|
||||||
this.parsedFilters
|
this.parsedFilters
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user