Custom channel emoticons WIP (#130):
* fix reset when opening multiple chat * disable default converseJs custom icons
This commit is contained in:
parent
47b580d132
commit
f1cf98921f
@ -114,28 +114,20 @@ function defaultConverseParams (
|
|||||||
params.clear_cache_on_logout = true
|
params.clear_cache_on_logout = true
|
||||||
params.allow_user_trust_override = false
|
params.allow_user_trust_override = false
|
||||||
|
|
||||||
// We must enable custom emoji category, that ConverseJS disables by default.
|
// We change emoji_categories to put custom first.
|
||||||
// We put it last by default, but first if there are any custom emojis for this chat.
|
// We set custom to null, it will be set to another value if custom emojis are enabled.
|
||||||
params.emoji_categories = Object.assign(
|
params.emoji_categories = {
|
||||||
{},
|
custom: null,
|
||||||
customEmojisUrl
|
smileys: ':grinning:',
|
||||||
? { custom: ':converse:' }
|
people: ':thumbsup:',
|
||||||
: {},
|
activity: ':soccer:',
|
||||||
{
|
travel: ':motorcycle:',
|
||||||
smileys: ':grinning:',
|
objects: ':bomb:',
|
||||||
people: ':thumbsup:',
|
nature: ':rainbow:',
|
||||||
activity: ':soccer:',
|
food: ':hotdog:',
|
||||||
travel: ':motorcycle:',
|
symbols: ':musical_note:',
|
||||||
objects: ':bomb:',
|
flags: ':flag_ac:'
|
||||||
nature: ':rainbow:',
|
}
|
||||||
food: ':hotdog:',
|
|
||||||
symbols: ':musical_note:',
|
|
||||||
flags: ':flag_ac:'
|
|
||||||
},
|
|
||||||
!customEmojisUrl
|
|
||||||
? { custom: ':converse:' }
|
|
||||||
: {}
|
|
||||||
)
|
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ export const livechatEmojisPlugin = {
|
|||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
// Now we must clone json, to avoid side effects when navigating between several videos.
|
||||||
json = JSON.parse(JSON.stringify(json))
|
json = JSON.parse(JSON.stringify(json))
|
||||||
json.custom = {}
|
json.custom = {}
|
||||||
@ -61,18 +59,14 @@ export const livechatEmojisPlugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in defaultCustom) {
|
|
||||||
if (key in json.custom) {
|
|
||||||
// Was overriden by the backend, skipping.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
json.custom[key] = defaultCustom[key]
|
|
||||||
}
|
|
||||||
|
|
||||||
// And if there was a default definition, using it for the custom cat icon.
|
// And if there was a default definition, using it for the custom cat icon.
|
||||||
|
// Else we fallback to the first.
|
||||||
|
// If none... just keep custom to null!
|
||||||
|
defaultDef ??= customs[0]
|
||||||
if (defaultDef) {
|
if (defaultDef) {
|
||||||
const cat = _converse.api.settings.get('emoji_categories')
|
const cat = _converse.api.settings.get('emoji_categories')
|
||||||
cat.custom = defaultDef.sn
|
cat.custom = defaultDef.sn
|
||||||
|
_converse.api.settings.set('emoji_categories', cat)
|
||||||
}
|
}
|
||||||
return json
|
return json
|
||||||
})
|
})
|
||||||
|
@ -311,13 +311,6 @@ export class Emojis {
|
|||||||
customEmojis.push(sanitized)
|
customEmojis.push(sanitized)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, the frontend does not implement isCategoryEmoji.
|
|
||||||
// if there is no isCategoryEmoji, we will take the first value.
|
|
||||||
// TODO: remove this when the frontend will be able to set this.
|
|
||||||
if (!categoryEmojiFound && customEmojis.length) {
|
|
||||||
customEmojis[0].isCategoryEmoji = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const result: ChannelEmojis = {
|
const result: ChannelEmojis = {
|
||||||
customEmojis: customEmojis
|
customEmojis: customEmojis
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user