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:
natreex
2025-11-18 22:17:22 -05:00
parent 004008cc13
commit 0bafaadecc
5 changed files with 128 additions and 9 deletions

View File

@@ -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);