explicit store typing

This commit is contained in:
Gauthier Roebroeck 2026-05-04 15:51:58 +08:00
parent 3066f1726d
commit 474904edb0
5 changed files with 32 additions and 13 deletions

View file

@ -553,7 +553,7 @@ function fetchBooks(book: BookImport) {
condition: {
seriesId: { operator: 'Is', value: book.series!.id },
},
} as components['schemas']['BookSearch'],
},
pageRequest: PageRequest.Unpaged(),
}),
)

View file

@ -492,7 +492,7 @@ const getSeriesBooks = useMemoize(async (seriesId: string) =>
condition: {
seriesId: { operator: 'Is', value: seriesId },
},
} as components['schemas']['BookSearch'],
},
}),
)
.refresh()

View file

@ -107,7 +107,7 @@ function showDialog(action: ACTION, user?: components['schemas']['UserDto']) {
age: 0,
restriction: 'NONE',
},
} as components['schemas']['UserCreationDto']
}
dialogConfirmEdit.value.callback = handleDialogConfirmation
break
case ACTION.EDIT:
@ -141,7 +141,7 @@ function showDialog(action: ACTION, user?: components['schemas']['UserDto']) {
age: 0,
restriction: 'NONE',
},
} as components['schemas']['UserUpdateDto']
}
dialogConfirmEdit.value.callback = handleDialogConfirmation
break
case ACTION.DELETE:

View file

@ -5,25 +5,38 @@ import type { PresentationMode } from '@/types/libraries'
import type { PageSize, Paging } from '@/types/page'
import type { Sort } from '@/types/PageRequest'
interface AppState {
drawer: boolean
theme: string
rememberMe: boolean
importBooksPath: string
browsingPageSize: PageSize
browsingPaging: Paging
presentationMode: Record<string, PresentationMode>
sortActive: Record<string, Sort[]>
gridCardWidth: number
reorderLibraries: boolean
}
export const useAppStore = defineStore('app', {
state: () => ({
state: (): AppState => ({
// persisted
drawer: !useDisplay().mobile.value.valueOf(),
theme: 'system',
rememberMe: false,
importBooksPath: '',
browsingPageSize: 20 as PageSize,
browsingPaging: 'scroll' as Paging,
browsingPageSize: 20,
browsingPaging: 'scroll',
/**
* Store the presentation mode per view.
* Use the getter to ensure a default value is always set.
*/
presentationMode: {} as Record<string, PresentationMode>,
presentationMode: {},
/**
* Store the sort order per view.
* Use the getter to ensure a default value is always set.
*/
sortActive: {} as Record<string, Sort[]>,
sortActive: {},
gridCardWidth: 150,
// transient
reorderLibraries: false,

View file

@ -2,12 +2,18 @@
import { defineStore } from 'pinia'
import type { DialogConfirmEditProps, DialogConfirmProps, DialogSimpleProps } from '@/types/dialog'
interface DialogsState {
confirmEdit: DialogConfirmEditActivation
confirm: DialogConfirmActivation
simple: DialogSimpleActivation
}
/**
* Reusable dialogs.
* The single instances of the dialogs are created under App, and can be triggered by using this store.
*/
export const useDialogsStore = defineStore('dialogs', {
state: () => ({
state: (): DialogsState => ({
confirmEdit: {
dialogProps: {},
slot: {
@ -17,7 +23,7 @@ export const useDialogsStore = defineStore('dialogs', {
},
record: undefined,
callback: () => {},
} as DialogConfirmEditActivation,
},
confirm: {
dialogProps: {},
slotWarning: {
@ -26,7 +32,7 @@ export const useDialogsStore = defineStore('dialogs', {
handlers: {},
},
callback: () => {},
} as DialogConfirmActivation,
},
simple: {
dialogProps: {},
slot: {
@ -35,7 +41,7 @@ export const useDialogsStore = defineStore('dialogs', {
handlers: {},
},
callback: () => {},
} as DialogSimpleActivation,
},
}),
})