mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 11:46:36 +08:00
fix issue 51 library reclassify regressions
This commit is contained in:
@@ -87,6 +87,13 @@ export const libraryAPI = {
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
get: (id: string, options?: { includeHidden?: boolean }) =>
|
||||
api
|
||||
.get<Library>(`/libraries/${id}`, {
|
||||
params: options?.includeHidden ? { include_hidden: 1 } : undefined,
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
create: (name: string, path: string, type: string) =>
|
||||
api.post<Library>('/libraries', { name, path, type }).then((r) => r.data),
|
||||
|
||||
|
||||
@@ -27,10 +27,24 @@ export function useLibraryData(libraryID: string, selectedSeries: SeriesCard | n
|
||||
|
||||
useEffect(() => {
|
||||
if (!libraryID) return
|
||||
libraryAPI.list().then((all) => {
|
||||
const lib = all.find((item) => item.id === libraryID) ?? null
|
||||
setLibrary(lib)
|
||||
})
|
||||
let cancelled = false
|
||||
setLoading(true)
|
||||
setLibrary(null)
|
||||
setItems([])
|
||||
setServerSeriesCards([])
|
||||
setSeriesEpisodeItems([])
|
||||
libraryAPI.get(libraryID)
|
||||
.then((lib) => {
|
||||
if (!cancelled) setLibrary(lib)
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) {
|
||||
setLibrary(null)
|
||||
setLoading(false)
|
||||
toast.error('媒体库不存在或无权限')
|
||||
}
|
||||
})
|
||||
return () => { cancelled = true }
|
||||
}, [libraryID])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user