Skip to content

Commit

Permalink
Fix settings migration for subscriptions identifiers to isChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Apr 5, 2024
1 parent d1c5e6f commit 4b507f0
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/subscriptionFetching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ export async function* fetchSubscriptions() {

const subChannels = await fApi.creator.channels([userSubscription.creator]);
for (const channel of subChannels) {
if (settingSubscription.channels.findIndex((chan) => chan.title === channel.title) === -1)
settingSubscription.channels.push({
title: channel.title,
skip: false,
isChannel:
channel.id === "6413623f5b12cca228a28e78"
? `(post, video) => isChannel(post, '${channel.id}') && !video?.title?.toLowerCase().startsWith('caption')`
: `(post) => isChannel(post, '${channel.id}')`,
});
const subChannel = settingSubscription.channels.find((chan) => chan.title === channel.title);
const channelDefaults = {
title: channel.title,
skip: false,
isChannel:
channel.id === "6413623f5b12cca228a28e78"
? `(post, video) => isChannel(post, '${channel.id}') && !video?.title?.toLowerCase().startsWith('caption')`
: `(post) => isChannel(post, '${channel.id}')`,
};
if (subChannel === undefined) {
settingSubscription.channels.push(channelDefaults);
} else if (subChannel.isChannel === undefined) {
// @ts-expect-error Identifiers have been replaced by isChannel
delete subChannel.identifiers;
subChannel.isChannel = channelDefaults.isChannel;
}
}

if (settingSubscription.skip === true) continue;
Expand Down

0 comments on commit 4b507f0

Please sign in to comment.