From 1465599bb8c82903747b9df127485d795c85d066 Mon Sep 17 00:00:00 2001 From: asivery Date: Sat, 2 Sep 2023 14:00:27 +0200 Subject: [PATCH] Fix song recognition --- src/main.ts | 11 ++++++++--- src/preload.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9c57058..3a85632 100644 --- a/src/main.ts +++ b/src/main.ts @@ -212,14 +212,19 @@ async function integrate(window: BrowserWindow) { handleBadSectorResolve = null; shouldAbortAtracDownload = false; + const enableHandleBadSector = allArgs[3].handleBadSector; + const enableShouldCancelImmediately = allArgs[3].handleBadSector; + allArgs[3] = { ...allArgs[3], - handleBadSector: allArgs[3].handleBadSector ? async (...args: any[]) => { + handleBadSector: async (...args: any[]) => { window.webContents.send('_atracdl_callback_handleBadSector', ...args); return await new Promise<"reload" | "abort" | "skip" | "yieldanyway">(res => handleBadSectorResolve = res); - } : undefined, - shouldCancelImmediately: allArgs[3].handleBadSector ? () => shouldAbortAtracDownload : undefined, + }, + shouldCancelImmediately: () => shouldAbortAtracDownload, }; + if(!enableHandleBadSector) delete allArgs[3].handleBadSector; + if(!enableShouldCancelImmediately) delete allArgs[3].shouldCancelImmediately; allArgs[2] = async (...args: any[]) => window.webContents.send('_callback', `_factory__exploitDownloadTrack_callback2`, ...args); diff --git a/src/preload.ts b/src/preload.ts index 37ae182..e585d28 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -59,8 +59,12 @@ import { NetMDFactoryService } from './wmd/original/services/interfaces/netmd'; const handleBadSector = args[3].handleBadSector; callbacks[`_factory__exploitDownloadTrack_callback2`] = args[2]; - args[3].shouldCancelImmediately = shouldCancelImmediately ? { interprocessType: 'nestedFunction' } as any : null; - args[3].handleBadSector = handleBadSector ? { interprocessType: 'nestedFunction' } as any : null; + args[3].shouldCancelImmediately = { interprocessType: 'nestedFunction' } as any; + args[3].handleBadSector = { interprocessType: 'nestedFunction' } as any; + + if(!shouldCancelImmediately) delete args[3].shouldCancelImmediately; + if(!handleBadSector) delete args[3].handleBadSector; + args[2] = { interprocessType: 'function' } as any; if(shouldCancelImmediately){ interval = setInterval(() => {