Fix #449: Remove the constraint for custom emojis shortnames to have ":" at the beginning and at the end.
This commit is contained in:
parent
bd211d777e
commit
934c07e34e
@ -7,6 +7,10 @@
|
||||
* #233: new option to [mute anonymous users](https://livingston.frama.io/peertube-plugin-livechat/documentation/user/streamers/moderation/).
|
||||
* #18: terms & conditions. You can configure terms&conditions on your instance that will be shown to each joining users. Streamers can also add [terms&conditions in their channels options](https://livingston.frama.io/peertube-plugin-livechat/documentation/user/streamers/terms/).
|
||||
|
||||
### Minor changes and fixes
|
||||
|
||||
* Fix #449: Remove the constraint for custom emojis shortnames to have ":" at the beginning and at the end.
|
||||
|
||||
## 10.1.2
|
||||
|
||||
* Fix: clicking on the import custom emojis button, without selected any file, was resulting in a state with all action button disabled.
|
||||
|
@ -193,9 +193,7 @@ export class ChannelEmojisElement extends LivechatElement {
|
||||
}
|
||||
|
||||
const url = await this._convertImageToDataUrl(entry.url)
|
||||
let sn = entry.sn as string
|
||||
if (!sn.startsWith(':')) { sn = ':' + sn }
|
||||
if (!sn.endsWith(':')) { sn += ':' }
|
||||
const sn = entry.sn as string
|
||||
|
||||
const item: ChannelEmojisConfiguration['emojis']['customEmojis'][0] = {
|
||||
sn,
|
||||
|
@ -91,12 +91,6 @@ export function tplChannelEmojis (el: ChannelEmojisElement): TemplateResult {
|
||||
el.resetValidation(e)
|
||||
if (el.channelEmojisConfiguration) {
|
||||
el.channelEmojisConfiguration.emojis.customEmojis = e.detail
|
||||
// Fixing missing ':' for shortnames:
|
||||
for (const desc of el.channelEmojisConfiguration.emojis.customEmojis) {
|
||||
if (desc.sn === '') { continue }
|
||||
if (!desc.sn.startsWith(':')) { desc.sn = ':' + desc.sn }
|
||||
if (!desc.sn.endsWith(':')) { desc.sn += ':' }
|
||||
}
|
||||
el.requestUpdate('channelEmojisConfiguration')
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ export class ChannelDetailsService {
|
||||
propertiesError[`emojis.${i}.sn`] = []
|
||||
if (e.sn === '') {
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.Missing)
|
||||
} else if (!/^:[\w-]+:$/.test(e.sn)) {
|
||||
} else if (!/^:?[\w-]+:?$/.test(e.sn)) { // optional ':' at the beggining and at the end
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.WrongFormat)
|
||||
} else if (seen.has(e.sn)) {
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.Duplicate)
|
||||
|
@ -512,7 +512,8 @@ livechat_configuration_channel_emojis_desc: |
|
||||
livechat_emojis_shortname: 'Short name'
|
||||
livechat_emojis_shortname_desc: |
|
||||
You can use emojis using ":shortname:".
|
||||
The short name can only contain alphanumerical characters, underscores and hyphens.
|
||||
The short name can start and/or end by a colon (:), and only contain alphanumerical characters, underscores and hyphens.
|
||||
It is strongly recommended to start them by a colon, so that users can use autocompletion (by typing ":" then press TAB).
|
||||
livechat_emojis_file: 'File'
|
||||
livechat_emojis_file_desc: |
|
||||
The emoji file.
|
||||
|
@ -141,7 +141,7 @@ export class Emojis {
|
||||
* @param sn short name
|
||||
*/
|
||||
public validShortName (sn: any): boolean {
|
||||
if ((typeof sn !== 'string') || !/^:[\w-]+:$/.test(sn)) {
|
||||
if ((typeof sn !== 'string') || !/^:?[\w-]+:?$/.test(sn)) {
|
||||
this.logger.debug('Short name invalid: ' + (typeof sn === 'string' ? sn : '???'))
|
||||
return false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user