Skip to content

Commit 135bfbe

Browse files
committed
fix: correctly report errors from worker loading
1 parent 8e144aa commit 135bfbe

4 files changed

Lines changed: 6 additions & 25 deletions

File tree

app/services/api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ export async function downloadStories(story: RemoteContent, folderId?: number) {
353353
true
354354
);
355355
DEV_LOG && console.warn('aimportContentFromFiles done');
356+
} catch (error) {
357+
showError(error);
358+
hideSnackMessage();
356359
} finally {
357360
if (file && File.exists(file.path)) {
358361
DEV_LOG && console.log('removing downloading file', file.path);

app/services/importservice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ImportEnabledEventData extends Optional<EventData<Observable>,
1717

1818
export class ImportService extends BaseWorkerHandler<ImportWorker> {
1919
constructor() {
20-
super(() => new Worker('~/workers/ImportWorkerBootstrap'));
20+
super(() => new Worker('~/workers/ImportWorker'));
2121
}
2222
async onWorkerEvent(eventData: any) {
2323
if (eventData.target === 'documentsService') {

app/workers/ImportWorker.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '@nativescript/core/globals';
12
import SqlQuery from '@akylas/kiss-orm/dist/Queries/SqlQuery';
23
import { getWorkerContextValue, loadImageSync, setWorkerContextValue } from '@akylas/nativescript-app-utils';
34
import { BaseWorker, WorkerEvent } from '@akylas/nativescript-app-utils/worker/BaseWorker';
@@ -461,26 +462,3 @@ export default class ImportWorker extends BaseWorker {
461462
}
462463

463464
const worker = new ImportWorker(context);
464-
const receivedMessage = worker.receivedMessage.bind(worker);
465-
context.onmessage = (event) => {
466-
// DEV_LOG && console.log(TAG, 'onmessage', Date.now(), event);
467-
if (typeof event.data.messageData === 'string') {
468-
try {
469-
event.data.messageData = JSON.parse(event.data.messageData);
470-
} catch (error) {}
471-
}
472-
if (Array.isArray(event.data.nativeData)) {
473-
event.data.nativeData = (event.data.nativeData as string[]).reduce((acc, key) => {
474-
const actualKey = key.split('$$$')[1];
475-
acc[actualKey] = getWorkerContextValue(key);
476-
setWorkerContextValue(key, null);
477-
return acc;
478-
}, {});
479-
}
480-
if (typeof event.data.error === 'string') {
481-
try {
482-
event.data.error = JSON.parse(event.data.error);
483-
} catch (error) {}
484-
}
485-
receivedMessage(event);
486-
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@akylas/kiss-orm": "2.1.11",
4141
"@akylas/nativescript": "8.8.10",
4242
"@akylas/nativescript-app-tools": "file:tools",
43-
"@akylas/nativescript-app-utils": "2.2.2",
43+
"@akylas/nativescript-app-utils": "2.2.3",
4444
"@akylas/nativescript-inapp-purchase": "0.0.4",
4545
"@akylas/nativescript-inappbrowser": "3.1.8",
4646
"@akylas/non-playstore": "portal:plugin_non_playstore",

0 commit comments

Comments
 (0)