fix: remove unnecessary JSON.stringify & JSON.parse

This commit is contained in:
JellyBrick
2023-09-30 08:43:10 +09:00
parent 72660f5aa1
commit 46d3a85cc0
6 changed files with 21 additions and 18 deletions

View File

@ -6,8 +6,8 @@ import { sortSegments } from './segments';
import { SkipSegment } from './types';
import defaultConfig from '../../config/defaults';
import { GetPlayerResponse } from '../../types/get-player-response';
import type { GetPlayerResponse } from '../../types/get-player-response';
import type { ConfigType } from '../../config/dynamic';
let videoID: string;
@ -18,8 +18,8 @@ export default (win: BrowserWindow, options: ConfigType<'sponsorblock'>) => {
...options,
};
ipcMain.on('video-src-changed', async (_, data: string) => {
videoID = (JSON.parse(data) as GetPlayerResponse)?.videoDetails?.videoId;
ipcMain.on('video-src-changed', async (_, data: GetPlayerResponse) => {
videoID = data?.videoDetails?.videoId;
const segments = await fetchSegments(apiURL, categories);
win.webContents.send('sponsorblock-skip', segments);
});