feat: enhance home and library pages by integrating new data fetching methods, improving error handling, and refactoring components for better structure
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m17s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m17s
This commit is contained in:
31
src/contexts/RefreshContext.tsx
Normal file
31
src/contexts/RefreshContext.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
"use client";
|
||||
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
|
||||
interface RefreshContextType {
|
||||
refreshLibrary?: (libraryId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
refreshSeries?: (seriesId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
}
|
||||
|
||||
const RefreshContext = createContext<RefreshContextType>({});
|
||||
|
||||
export function RefreshProvider({
|
||||
children,
|
||||
refreshLibrary,
|
||||
refreshSeries,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
refreshLibrary?: (libraryId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
refreshSeries?: (seriesId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
}) {
|
||||
return (
|
||||
<RefreshContext.Provider value={{ refreshLibrary, refreshSeries }}>
|
||||
{children}
|
||||
</RefreshContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useRefresh() {
|
||||
return useContext(RefreshContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user