Skip to content

Commit

Permalink
Add missing Electron guards after #4230 (#4311)
Browse files Browse the repository at this point in the history
* Add missing Electron guards after #4230

* Fix logic issue
  • Loading branch information
absidue authored Nov 11, 2023
1 parent e7a1b8b commit 61fc91f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/renderer/helpers/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getLocalChannel } from './api/local'
*/
async function findChannelById(id, backendOptions) {
try {
if (backendOptions.preference === 'invidious') {
if (!process.env.IS_ELECTRON || backendOptions.preference === 'invidious') {
return await invidiousGetChannelInfo(id)
} else {
return await getLocalChannel(id)
Expand All @@ -21,11 +21,15 @@ async function findChannelById(id, backendOptions) {
if (err.message && err.message === 'This channel does not exist.') {
return { invalid: true }
}
if (backendOptions.fallback && backendOptions.preference === 'invidious') {
return await getLocalChannel(id)
}
if (backendOptions.fallback && backendOptions.preference === 'local') {
return await invidiousGetChannelInfo(id)
if (process.env.IS_ELECTRON && backendOptions.fallback) {
if (backendOptions.preference === 'invidious') {
return await getLocalChannel(id)
}
if (backendOptions.preference === 'local') {
return await invidiousGetChannelInfo(id)
}
} else {
throw err
}
}
}
Expand All @@ -36,13 +40,13 @@ async function findChannelById(id, backendOptions) {
* preference: string,
* fallback: boolean,
* }} backendOptions
* @returns {Promise<{icon: string, iconHref: string, preferredName: string, invalidId: boolean}>}
* @returns {Promise<{icon: string, iconHref: string, preferredName: string} | { invalidId: boolean }>}
*/
export async function findChannelTagInfo(id, backendOptions) {
if (!/UC\S{22}/.test(id)) return { invalidId: true }
try {
const channel = await findChannelById(id, backendOptions)
if (backendOptions.preference === 'invidious') {
if (!process.env.IS_ELECTRON || backendOptions.preference === 'invidious') {
if (channel.invalid) return { invalidId: true }
return {
preferredName: channel.author,
Expand Down

0 comments on commit 61fc91f

Please sign in to comment.