Update update.ts

This commit is contained in:
freearhey 2025-01-18 14:04:45 +03:00
parent 106acefe87
commit 418d428b6f

View file

@ -85,6 +85,8 @@ async function editChannels({ loader, idCreator }: { loader: IssueLoader; idCrea
const country = data.getString('country') || found.country
if (name && country) {
channelId = idCreator.create(name, country)
updateBlocklistId(found.id, channelId)
updateChannelReplacedBy(found.id, channelId)
}
}
@ -196,3 +198,23 @@ async function blockChannels({ loader }: { loader: IssueLoader }) {
processedIssues.push(issue)
})
}
function updateBlocklistId(oldId: string, newId: string) {
const filtered: Collection = blocklist.filter((blocked: Blocked) => blocked.channel === oldId)
if (filtered.isEmpty()) return
filtered.forEach(item => {
item.channel = newId
})
}
function updateChannelReplacedBy(channelId: string, newReplacedBy: string) {
const filtered: Collection = channels.filter(
(channel: Channel) => channel.replaced_by === channelId
)
if (filtered.isEmpty()) return
filtered.forEach(item => {
item.replaced_by = newReplacedBy
})
}