Migrate from window.electron to tauri IPC functions across components
- Replaced `window.electron.invoke` calls with equivalent `tauri` function calls for all IPC interactions. - Removed `electron.d.ts` TypeScript definitions as they are no longer needed. - Updated related logic for offline/online state synchronization. - Added `types.rs` and `shared/mod.rs` modules to support Tauri IPC integration with Rust enums and shared logic. - Refactored IPC request queues to use updated handler names for consistency with Tauri.
This commit is contained in:
@@ -12,6 +12,7 @@ import {BooksSyncContext, BooksSyncContextProps} from '@/context/BooksSyncContex
|
||||
import {BookContext} from '@/context/BookContext';
|
||||
import {SyncedBook} from '@/lib/models/SyncedBook';
|
||||
import System from '@/lib/models/System';
|
||||
import * as tauri from '@/lib/tauri';
|
||||
|
||||
export type SyncElementType = 'character' | 'world' | 'location' | 'spell';
|
||||
|
||||
@@ -72,10 +73,8 @@ export default function SyncFieldWrapper({
|
||||
let response: SeriesSyncUploadResponse;
|
||||
|
||||
if (isCurrentlyOffline() || book?.localBook) {
|
||||
// Offline OU livre local → IPC
|
||||
response = await window.electron.invoke<SeriesSyncUploadResponse>('db:series:sync:upload', requestData);
|
||||
response = await tauri.seriesSyncUpload(requestData) as SeriesSyncUploadResponse;
|
||||
} else {
|
||||
// Online + livre serveur → Server
|
||||
response = await System.authPostToServer<SeriesSyncUploadResponse>(
|
||||
'series/propagate',
|
||||
requestData,
|
||||
@@ -83,9 +82,8 @@ export default function SyncFieldWrapper({
|
||||
lang
|
||||
);
|
||||
|
||||
// Si le livre a une copie locale → addToQueue pour sync
|
||||
if (book?.bookId && localSyncedBooks.find((sb: SyncedBook): boolean => sb.id === book.bookId)) {
|
||||
addToQueue('db:series:sync:upload', requestData);
|
||||
addToQueue('series_sync_upload', {data: requestData});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user