Refactor IPC handlers, types, and models for streamlined data handling

- Unified return types across IPC handlers (`Character`, `Location`, `World`, and `Book`) for consistency.
- Replaced `BookListProps` with `BookProps` for simplified type usage in components and handlers.
- Cleaned up obsolete `BookListProps` interface and applied consistent typings throughout.
- Updated imports to include revised response types (`CharacterListResponse`, `LocationListResponse`, `WorldListResponse`).
- Adjusted data transformation logic in `BookList` and related components to align with new type definitions.
This commit is contained in:
natreex
2026-01-15 16:12:20 -05:00
parent e45a15225b
commit 3d4feaa680
6 changed files with 33 additions and 50 deletions

View File

@@ -1,7 +1,7 @@
import { ipcMain } from 'electron';
import { createHandler } from '../database/LocalSystem.js';
import Character from '../database/models/Character.js';
import type { CharacterProps, CharacterPropsPost, CharacterAttribute } from '../database/models/Character.js';
import Character, {CharacterListResponse} from '../database/models/Character.js';
import type { CharacterPropsPost, CharacterAttribute } from '../database/models/Character.js';
interface AddCharacterData {
character: CharacterPropsPost;
@@ -20,8 +20,8 @@ interface AddAttributeData {
interface GetCharacterListData {
bookid: string;
}
ipcMain.handle('db:character:list', createHandler<GetCharacterListData, CharacterProps[]>(
function(userId: string, data: GetCharacterListData, lang: 'fr' | 'en'): CharacterProps[] {
ipcMain.handle('db:character:list', createHandler<GetCharacterListData, CharacterListResponse>(
function(userId: string, data: GetCharacterListData, lang: 'fr' | 'en'): CharacterListResponse {
return Character.getCharacterList(userId, data.bookid, lang);
}
)