Custom channel emoticons WIP (#130)

This commit is contained in:
John Livingston
2024-06-06 15:03:12 +02:00
parent 893708d93a
commit a777c7ac8d
12 changed files with 56 additions and 17 deletions

View File

@ -33,8 +33,10 @@ export const livechatEmojisPlugin = {
return json
}
// We will put default emojis at the end
// We will put default emojis at the end, so keeping a copy
const defaultCustom = json.custom ?? {}
// Now we must clone json, to avoid side effects when navigating between several videos.
json = JSON.parse(JSON.stringify(json))
json.custom = {}
let defaultDef: CustomEmojiDefinition | undefined
@ -48,6 +50,15 @@ export const livechatEmojisPlugin = {
if (def.isCategoryEmoji) {
defaultDef ??= def
}
// We must also remove any existing emojis in category other than custom
for (const type of Object.keys(json)) {
const v: {[key: string]: any} = json[type]
if (type !== 'custom' && type !== 'modifiers' && (def.sn in v)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete v[def.sn]
}
}
}
for (const key in defaultCustom) {