Add multi-language support and new repository methods for book synchronization
- Extend repository methods to handle API requests for fetching books, chapters, characters, and other entities with multilingual support (`lang: 'fr' | 'en'`). - Add `uploadBookForSync` logic to consolidate and decrypt book data for synchronization. - Refactor schema migration logic to remove console logs and streamline table recreation. - Enhance error handling across database repositories and IPC methods.
This commit is contained in:
19
app/page.tsx
19
app/page.tsx
@@ -30,7 +30,7 @@ import {NextIntlClientProvider, useTranslations} from "next-intl";
|
||||
import {LangContext} from "@/context/LangContext";
|
||||
import {AIUsageContext} from "@/context/AIUsageContext";
|
||||
import OfflineProvider from "@/context/OfflineProvider";
|
||||
import OfflineContext from "@/context/OfflineContext";
|
||||
import OfflineContext, {OfflineMode} from "@/context/OfflineContext";
|
||||
import OfflinePinSetup from "@/components/offline/OfflinePinSetup";
|
||||
import OfflinePinVerify from "@/components/offline/OfflinePinVerify";
|
||||
import {SyncedBook, BookSyncCompare, compareBookSyncs} from "@/lib/models/SyncedBook";
|
||||
@@ -234,7 +234,6 @@ function ScribeContent() {
|
||||
|
||||
if (!offlineStatus.hasPin) {
|
||||
setTimeout(():void => {
|
||||
console.log('[Page] Showing PIN setup dialog');
|
||||
setShowPinSetup(true);
|
||||
}, 2000);
|
||||
}
|
||||
@@ -374,13 +373,12 @@ function ScribeContent() {
|
||||
username: user.username,
|
||||
email: user.email
|
||||
});
|
||||
console.log('User synced to local DB');
|
||||
} catch (syncError) {
|
||||
console.error('Failed to sync user to local DB:', syncError);
|
||||
errorMessage(t("homePage.errors.syncError"));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize database:', error);
|
||||
errorMessage(t("homePage.errors.syncError"));
|
||||
}
|
||||
}
|
||||
setSession({
|
||||
@@ -396,7 +394,7 @@ function ScribeContent() {
|
||||
const offlineStatus = await window.electron.offlineModeGet();
|
||||
|
||||
if (offlineStatus.hasPin && offlineStatus.lastUserId) {
|
||||
setOfflineMode(prev => ({...prev, isOffline: true, isNetworkOnline: false}));
|
||||
setOfflineMode((prev:OfflineMode):OfflineMode => ({...prev, isOffline: true, isNetworkOnline: false}));
|
||||
setShowPinVerify(true);
|
||||
setIsLoading(false);
|
||||
return;
|
||||
@@ -407,7 +405,7 @@ function ScribeContent() {
|
||||
}
|
||||
}
|
||||
} catch (offlineError) {
|
||||
console.error('[Auth] Error checking offline mode:', offlineError);
|
||||
errorMessage(t("homePage.errors.offlineError"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +427,7 @@ function ScribeContent() {
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Auth] Error checking offline mode:', error);
|
||||
errorMessage(t("homePage.errors.authenticationError"));
|
||||
}
|
||||
window.electron.logout();
|
||||
}
|
||||
@@ -557,10 +555,9 @@ function ScribeContent() {
|
||||
showPinSetup && window.electron && (
|
||||
<OfflinePinSetup
|
||||
showOnFirstLogin={true}
|
||||
onClose={() => setShowPinSetup(false)}
|
||||
onSuccess={() => {
|
||||
onClose={():void => setShowPinSetup(false)}
|
||||
onSuccess={():void => {
|
||||
setShowPinSetup(false);
|
||||
console.log('[Page] PIN configured successfully');
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user