mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
ee5068c98c
* feat(artist): year sort for albums section on artist detail Add a sort dropdown next to "Albums by …" with release-type grouping (default), newest-first, and oldest-first by album year. * chore: note PR #877 in CHANGELOG and settings credits * fix(artist): toggle year sort inside release groups, session per server Replace dropdown with a click-to-toggle newest/oldest button. Keep release-type blocks; sort albums by year within each group. Persist order in session store.
28 lines
913 B
TypeScript
28 lines
913 B
TypeScript
import { create } from 'zustand';
|
|
|
|
import type { ArtistAlbumYearOrder } from '../utils/library/sortArtistAlbums';
|
|
|
|
export const DEFAULT_ARTIST_ALBUM_YEAR_ORDER: ArtistAlbumYearOrder = 'yearDesc';
|
|
|
|
interface ArtistAlbumYearSortStore {
|
|
orderByServer: Record<string, ArtistAlbumYearOrder>;
|
|
yearOrderFor: (serverId: string) => ArtistAlbumYearOrder;
|
|
toggleYearOrder: (serverId: string) => void;
|
|
}
|
|
|
|
export const useArtistAlbumYearSortStore = create<ArtistAlbumYearSortStore>((set, get) => ({
|
|
orderByServer: {},
|
|
|
|
yearOrderFor: (serverId) =>
|
|
get().orderByServer[serverId] ?? DEFAULT_ARTIST_ALBUM_YEAR_ORDER,
|
|
|
|
toggleYearOrder: (serverId) => {
|
|
if (!serverId) return;
|
|
const current = get().yearOrderFor(serverId);
|
|
const next: ArtistAlbumYearOrder = current === 'yearDesc' ? 'yearAsc' : 'yearDesc';
|
|
set(s => ({
|
|
orderByServer: { ...s.orderByServer, [serverId]: next },
|
|
}));
|
|
},
|
|
}));
|