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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user