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

@@ -15,6 +15,26 @@ export interface GuideTour {
[key: string]: boolean;
}
interface BookSummary {
bookId: string;
title: string;
subTitle?: string;
}
export interface UserInfoResponse {
id: string;
name: string;
lastName: string;
username: string;
email: string;
accountVerified: boolean;
authorName: string;
groupId: number;
termsAccepted: boolean;
guideTour: any[];
books: BookSummary[];
}
export default class User{
private readonly id:string;
@@ -52,7 +72,7 @@ export default class User{
this.termsAccepted = data.term_accepted === 1;
}
public static async returnUserInfos(userId: string) {
public static async returnUserInfos(userId: string):Promise<UserInfoResponse> {
const user: User = new User(userId);
await user.getUserInfos();
const books: BookProps[] = await Book.getBooks(userId);
@@ -68,7 +88,7 @@ export default class User{
groupId: user.getGroupId(),
termsAccepted: user.isTermsAccepted(),
guideTour: guideTour,
books: books.map((book: BookProps) => {
books: books.map((book: BookProps):BookSummary => {
return {
bookId: book.id,
title: book.title,