Album list updates

This commit is contained in:
jeffvli
2022-11-06 00:08:22 -07:00
parent 07123615ca
commit 633c6416df
9 changed files with 710 additions and 99 deletions
+25 -1
View File
@@ -1,7 +1,7 @@
import create from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import { Platform } from '@/renderer/types';
import { CardDisplayType, Platform } from '@/renderer/types';
type SidebarProps = {
expanded: string[];
@@ -11,7 +11,18 @@ type SidebarProps = {
rightWidth: string;
};
type LibraryPageProps = {
list: ListProps;
};
type ListProps = {
display: CardDisplayType;
size: number;
type: 'list' | 'grid';
};
export interface AppState {
albums: LibraryPageProps;
platform: Platform;
sidebar: {
expanded: string[];
@@ -24,6 +35,7 @@ export interface AppState {
export interface AppSlice extends AppState {
setAppStore: (data: Partial<AppSlice>) => void;
setPage: (page: 'albums', options: Partial<LibraryPageProps>) => void;
setSidebar: (options: Partial<SidebarProps>) => void;
}
@@ -31,10 +43,22 @@ export const useAppStore = create<AppSlice>()(
persist(
devtools(
immer((set, get) => ({
albums: {
list: {
display: CardDisplayType.CARD,
size: 50,
type: 'list',
},
},
platform: Platform.WINDOWS,
setAppStore: (data) => {
set({ ...get(), ...data });
},
setPage: (page: 'albums', data: any) => {
set((state) => {
state[page] = { ...state[page], ...data };
});
},
setSidebar: (options) => {
set((state) => {
state.sidebar = { ...state.sidebar, ...options };