Skip to content

Commit efce573

Browse files
committed
fix translation logic bugs
1 parent 8c39de5 commit efce573

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

packages/raga-web-app/src/store/slices/audioFilesServerSlice.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { withTimeout } from "../../common/asyncUtils";
1010
import {
1111
AUDIO_FILES_SERVER_PING_TIMEOUT,
1212
DEFAULT_AUDIO_FILES_SERVER_PORT,
13+
WRITE_AUDIO_FILE_TAG_TIMEOUT,
1314
} from "../../common/constants";
1415
import {
1516
type AudioFilesServerStartedEventPayload,
@@ -218,8 +219,11 @@ export const createAudioFilesServerSlice: AppStoreSliceCreator<
218219
} satisfies WriteAudioFileTagOptions);
219220

220221
try {
221-
yield* call(() =>
222-
window.api.waitForResponse(ServerEventChannel.WRITE_AUDIO_FILE_TAG_COMPLETE),
222+
yield* call(
223+
window.api.waitForResponse(
224+
ServerEventChannel.WRITE_AUDIO_FILE_TAG_COMPLETE,
225+
WRITE_AUDIO_FILE_TAG_TIMEOUT,
226+
),
223227
);
224228

225229
log.info(`[client] completed updating '${tagName}' tag for track ${trackID.toString()}`);

packages/raga-web-app/src/store/slices/librarySlice.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import { call, type Operation } from "effection";
77
import { Roarr as log } from "roarr";
88

9-
import { DEBUG } from "../../common/constants";
9+
import { DEBUG, LOAD_SWINSIAN_LIBRARY_TIMEOUT } from "../../common/constants";
1010
import { ClientErrors } from "../../common/errorMessages";
1111
import {
1212
ClientEventChannel,
@@ -201,10 +201,12 @@ export const createLibrarySlice: AppStoreSliceCreator<LibraryState & LibraryActi
201201
return;
202202
} else {
203203
// In desktop mode, use IPC
204+
log.debug("[client] Sending load library request via IPC");
204205
window.api.send(ClientEventChannel.LOAD_SWINSIAN_LIBRARY, options);
205-
data = yield* call(() =>
206+
data = yield* call(
206207
window.api.waitForResponse<LoadedSwinsianLibraryEventPayload>(
207208
ServerEventChannel.LOADED_SWINSIAN_LIBRARY,
209+
LOAD_SWINSIAN_LIBRARY_TIMEOUT,
208210
),
209211
);
210212
}
@@ -275,9 +277,7 @@ export const createLibrarySlice: AppStoreSliceCreator<LibraryState & LibraryActi
275277
});
276278

277279
try {
278-
yield* call(() =>
279-
window.api.waitForResponse(ServerEventChannel.WRITE_MODIFIED_LIBRARY_COMPLETE),
280-
);
280+
yield* call(window.api.waitForResponse(ServerEventChannel.WRITE_MODIFIED_LIBRARY_COMPLETE));
281281
set({ libraryWriteState: "none" });
282282
} catch {
283283
log.error(ClientErrors.LIBRARY_WRITE_TIMED_OUT);

packages/raga-web-app/src/webApi.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export interface WebContextBridgeApi {
1212
// Mock IPC methods
1313
send: (channel: ClientEventChannel, ...args: unknown[]) => void;
1414
handleOnce: <T = unknown>(channel: ServerEventChannel, callback: (payload: T) => void) => void;
15-
waitForResponse: <T = unknown>(channel: ServerEventChannel) => Promise<T>;
15+
waitForResponse: <T = unknown>(
16+
channel: ServerEventChannel,
17+
timeoutMs?: number,
18+
) => () => Promise<T>;
1619

1720
// File operations
1821
getFilePath: (file: File | null | undefined) => string | undefined;
@@ -23,18 +26,6 @@ class WebApi implements WebContextBridgeApi {
2326

2427
private pendingCallbacks = new Map<string, ((payload: unknown) => void)[]>();
2528

26-
// constructor() {
27-
// // Detect actual platform if possible
28-
// const userAgent = navigator.userAgent.toLowerCase();
29-
// if (userAgent.includes("mac")) {
30-
// this.platform = "darwin";
31-
// } else if (userAgent.includes("win")) {
32-
// this.platform = "win32";
33-
// } else if (userAgent.includes("linux")) {
34-
// this.platform = "linux";
35-
// }
36-
// }
37-
3829
send(channel: ClientEventChannel, ...args: unknown[]): void {
3930
console.warn(`[WebApi] IPC send called with channel: ${String(channel)}`, args);
4031
// In a real implementation, this could send requests to a backend API
@@ -48,10 +39,11 @@ class WebApi implements WebContextBridgeApi {
4839
this.pendingCallbacks.set(channelKey, callbacks);
4940
}
5041

51-
async waitForResponse<T = unknown>(channel: ServerEventChannel): Promise<T> {
42+
waitForResponse<T = unknown>(channel: ServerEventChannel, _timeoutMs = 0): () => Promise<T> {
5243
console.warn(`[WebApi] IPC waitForResponse called with channel: ${String(channel)}`);
53-
// Return a rejected promise for now - in a real implementation this would wait for backend response
54-
return Promise.reject(new Error(`Web API does not support IPC channel: ${String(channel)}`));
44+
// Return a function that returns a rejected promise for now - in a real implementation this would wait for backend response
45+
return () =>
46+
Promise.reject(new Error(`Web API does not support IPC channel: ${String(channel)}`));
5547
}
5648

5749
getFilePath(file: File | null | undefined): string | undefined {

0 commit comments

Comments
 (0)