Files
ERitors-Scribe-Desktop/context/OfflineContext.ts
natreex a114592ac9 Add terms of use translations, sync detection, and refactor book components
- Introduced new translations for terms of use in French and English locales.
- Added sync status detection logic for books in `BookList` and `BookCard` components.
- Refactored `BookCard` to handle additional props and improve layout flexibility.
- Enhanced `TermsOfUse` component with complete localization support and refuse functionality.
- Updated data decryption logic in Rust services to handle optional fields and additional metadata consistently.
- Improved offline/online synchronization workflows with extended context properties.
2026-03-23 11:56:35 -04:00

36 lines
1.0 KiB
TypeScript

import {createContext, Dispatch, SetStateAction} from 'react';
export interface OfflineMode {
isManuallyOffline: boolean;
isNetworkOnline: boolean;
isOffline: boolean;
isDatabaseInitialized: boolean;
error: string | null;
}
export interface OfflineContextType {
offlineMode: OfflineMode;
setOfflineMode: Dispatch<SetStateAction<OfflineMode>>;
toggleOfflineMode: () => void;
initializeDatabase: (userId: string, encryptionKey?: string) => Promise<boolean>;
isCurrentlyOffline: () => boolean;
}
export const defaultOfflineMode: OfflineMode = {
isManuallyOffline: false,
isNetworkOnline: typeof navigator !== 'undefined' ? navigator.onLine : true,
isOffline: false,
isDatabaseInitialized: false,
error: null
};
const OfflineContext = createContext<OfflineContextType>({
offlineMode: defaultOfflineMode,
setOfflineMode: () => {},
toggleOfflineMode: () => {},
initializeDatabase: async () => false,
isCurrentlyOffline: () => false
});
export default OfflineContext;