From d15dd43d073ca755ac0a6993493b0d4e7629e66d Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:39:59 -0500 Subject: [PATCH] fix loading invidious instances from static file for electron builds (#4681) --- src/renderer/store/modules/invidious.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/renderer/store/modules/invidious.js b/src/renderer/store/modules/invidious.js index 759632e2d..b7b9aa414 100644 --- a/src/renderer/store/modules/invidious.js +++ b/src/renderer/store/modules/invidious.js @@ -39,6 +39,7 @@ const actions = { console.error(err) } } + // If the invidious instance fetch isn't returning anything interpretable if (instances.length === 0) { // Fallback: read from static file @@ -46,15 +47,13 @@ const actions = { /* eslint-disable-next-line n/no-path-concat */ const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/` const filePath = `${fileLocation}${fileName}` - if (!process.env.IS_ELECTRON) { - console.warn('reading static file for invidious instances') - const fileData = process.env.IS_ELECTRON ? await fs.readFile(filePath, 'utf8') : await (await fetch(createWebURL(filePath))).text() - instances = JSON.parse(fileData).filter(e => { - return process.env.IS_ELECTRON || e.cors - }).map(e => { - return e.url - }) - } + console.warn('reading static file for invidious instances') + const fileData = process.env.IS_ELECTRON ? await fs.readFile(filePath, 'utf8') : await (await fetch(createWebURL(filePath))).text() + instances = JSON.parse(fileData).filter(e => { + return process.env.IS_ELECTRON || e.cors + }).map(e => { + return e.url + }) } commit('setInvidiousInstancesList', instances) },