Add BooksSyncContext, refine database schema, and enhance synchronization support
- Introduce `BooksSyncContext` for managing book synchronization states (server-only, local-only, to-sync, etc.). - Remove `UserContext` and related dependencies. - Refine localization strings (`en.json`) with sync-related updates (e.g., "toSyncFromServer", "toSyncToServer"). - Extend database schema with additional tables and fields for syncing books, chapters, and related entities. - Add `last_update` fields and update corresponding repository methods to support synchronization logic. - Enhance IPC handlers with stricter typing, data validation, and sync-aware operations.
This commit is contained in:
22
context/BooksSyncContext.ts
Normal file
22
context/BooksSyncContext.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import {SyncedBook} from "@/lib/models/SyncedBook";
|
||||
import {Context, createContext} from "react";
|
||||
|
||||
export type SyncType = 'server-only' | 'local-only' | 'to-sync-from-server' | 'to-sync-to-server' | 'synced'
|
||||
|
||||
export interface BooksSyncContextProps {
|
||||
serverSyncedBooks:SyncedBook[];
|
||||
localSyncedBooks:SyncedBook[];
|
||||
booksToSyncFromServer:SyncedBook[];
|
||||
booksToSyncToServer:SyncedBook[];
|
||||
serverOnlyBooks:SyncedBook[];
|
||||
localOnlyBooks:SyncedBook[];
|
||||
}
|
||||
|
||||
export const BooksSyncContext:Context<BooksSyncContextProps> = createContext<BooksSyncContextProps>({
|
||||
serverSyncedBooks:[],
|
||||
localSyncedBooks:[],
|
||||
booksToSyncFromServer:[],
|
||||
booksToSyncToServer:[],
|
||||
serverOnlyBooks:[],
|
||||
localOnlyBooks:[]
|
||||
})
|
||||
@@ -1,25 +0,0 @@
|
||||
import {UserProps} from "@/lib/models/User";
|
||||
import {Context, createContext} from "react";
|
||||
|
||||
export interface UserContextProps {
|
||||
user: UserProps
|
||||
}
|
||||
|
||||
export const UserContext: Context<UserContextProps> = createContext<UserContextProps>({
|
||||
user: {
|
||||
id: '',
|
||||
name: '',
|
||||
lastName: '',
|
||||
username: '',
|
||||
writingLang: 0,
|
||||
writingLevel: 0,
|
||||
ritePoints: 0,
|
||||
groupId: 0,
|
||||
aiUsage: 0,
|
||||
apiKeys: {
|
||||
openai: false,
|
||||
anthropic: false,
|
||||
gemini: false,
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user