Add user data synchronization and database IPC handlers
- Introduce `db:user:sync` to synchronize user data with the local database during initialization. - Add `db:user:info` and `db:user:update` IPC handlers for fetching and updating user information. - Update `User` model and repository to support extended user fields and improved structure. - Dynamically import user models in main process to avoid circular dependencies. - Refactor database initialization in the app to include user sync logic with error handling.
This commit is contained in:
16
app/page.tsx
16
app/page.tsx
@@ -226,7 +226,21 @@ function ScribeContent() {
|
||||
const dbInitialized = await initializeDatabase(user.id);
|
||||
if (dbInitialized) {
|
||||
console.log('Database initialized successfully');
|
||||
// TODO: Sync initial des données du serveur vers la DB locale
|
||||
|
||||
// Sync user to local DB (only if not exists)
|
||||
try {
|
||||
await window.electron.invoke('db:user:sync', {
|
||||
userId: user.id,
|
||||
firstName: user.name,
|
||||
lastName: user.lastName,
|
||||
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);
|
||||
// Non-blocking error, continue anyway
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize database:', error);
|
||||
|
||||
Reference in New Issue
Block a user