Skip to content

Commit

Permalink
Fix for undefined default sub channels. RE #145, #135
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Feb 10, 2023
1 parent 4de6682 commit 726c2c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/defaults.ts
@@ -1,7 +1,7 @@
import { Resolutions, SubChannels, Settings, Args } from "./types.js";

export const defaultResolutions: Resolutions = ["360", "720", "1080", "2160"];
export const defaultSubChannels: { [key: string]: SubChannels } = {
export const defaultSubChannels: Record<string, SubChannels> = {
"Tech Deals": [
{
title: "Teach Deals",
Expand Down
8 changes: 5 additions & 3 deletions src/subscriptionFetching.ts
Expand Up @@ -20,9 +20,11 @@ export const fetchSubscriptions = async (): Promise<Subscription[]> =>
if (sub.channels !== undefined && !Array.isArray(sub.channels)) sub.channels = Object.values(sub.channels);

// Make sure that new subchannels from defaults are added to settings
const channelsToAdd = defaultSubChannels[titleAlias].filter((channel) => sub.channels.findIndex((chan) => chan.title === channel.title) === -1);
if (channelsToAdd.length > 0) {
sub.channels = [...sub.channels, ...channelsToAdd];
if (defaultSubChannels[titleAlias] !== undefined) {
const channelsToAdd = defaultSubChannels[titleAlias].filter((channel) => sub.channels.findIndex((chan) => chan.title === channel.title) === -1);
if (channelsToAdd.length > 0) {
sub.channels = [...sub.channels, ...channelsToAdd];
}
}

// If a default channel isnt specified for this in defaultSubChannels then create a default
Expand Down

0 comments on commit 726c2c5

Please sign in to comment.