Custom channel emoticons WIP (#130)
This commit is contained in:
1
client/@types/global.d.ts
vendored
1
client/@types/global.d.ts
vendored
@ -88,6 +88,7 @@ declare const LOC_INVALID_VALUE_WRONG_TYPE: string
|
||||
declare const LOC_INVALID_VALUE_WRONG_FORMAT: string
|
||||
declare const LOC_INVALID_VALUE_NOT_IN_RANGE: string
|
||||
declare const LOC_INVALID_VALUE_FILE_TOO_BIG: string
|
||||
declare const LOC_INVALID_VALUE_DUPLICATE: string
|
||||
|
||||
declare const LOC_CHATROOM_NOT_ACCESSIBLE: string
|
||||
|
||||
|
@ -182,12 +182,17 @@ export class ChannelDetailsService {
|
||||
public async validateEmojisConfiguration (channelEmojis: ChannelEmojis): Promise<boolean> {
|
||||
const propertiesError: ValidationError['properties'] = {}
|
||||
|
||||
const seen = new Map<string, true>()
|
||||
for (const [i, e] of channelEmojis.customEmojis.entries()) {
|
||||
propertiesError[`emojis.${i}.sn`] = []
|
||||
if (e.sn === '') {
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.Missing)
|
||||
} else if (!/^:[\w-]+:$/.test(e.sn)) {
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.WrongFormat)
|
||||
} else if (seen.has(e.sn)) {
|
||||
propertiesError[`emojis.${i}.sn`].push(ValidationErrorType.Duplicate)
|
||||
} else {
|
||||
seen.set(e.sn, true)
|
||||
}
|
||||
|
||||
propertiesError[`emojis.${i}.url`] = []
|
||||
|
@ -617,6 +617,9 @@ export class DynamicTableFormElement extends LivechatElement {
|
||||
if (validationErrorTypes.includes(ValidationErrorType.NotInRange)) {
|
||||
errorMessages.push(html`${ptTr(LOC_INVALID_VALUE_NOT_IN_RANGE)}`)
|
||||
}
|
||||
if (validationErrorTypes.includes(ValidationErrorType.Duplicate)) {
|
||||
errorMessages.push(html`${ptTr(LOC_INVALID_VALUE_DUPLICATE)}`)
|
||||
}
|
||||
|
||||
return html`<div id="${inputId}-feedback" class="invalid-feedback">${errorMessages}</div>`
|
||||
} else {
|
||||
|
@ -8,7 +8,6 @@ import { registerClientOptionsContext } from '../contexts/peertube'
|
||||
import { html } from 'lit'
|
||||
import { customElement, property } from 'lit/decorators.js'
|
||||
import { consume } from '@lit/context'
|
||||
import { ifDefined } from 'lit/directives/if-defined.js'
|
||||
|
||||
/**
|
||||
* Special element to upload image files.
|
||||
@ -40,7 +39,6 @@ export class ImageFileInputElement extends LivechatElement {
|
||||
public accept: string[] = ['image/jpg', 'image/png', 'image/gif']
|
||||
|
||||
protected override render = (): unknown => {
|
||||
// FIXME: limit file size in the upload field.
|
||||
return html`
|
||||
${this.value
|
||||
? html`<img src=${this.value} @click=${(ev: Event) => {
|
||||
@ -57,11 +55,6 @@ export class ImageFileInputElement extends LivechatElement {
|
||||
style=${this.value ? 'visibility: hidden;' : ''}
|
||||
@change=${async (ev: Event) => this._upload(ev)}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
name=${ifDefined(this.name)}
|
||||
value=${this.value ?? ''}
|
||||
/>
|
||||
`
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ export enum ValidationErrorType {
|
||||
WrongType,
|
||||
WrongFormat,
|
||||
NotInRange,
|
||||
Duplicate
|
||||
}
|
||||
|
||||
export class ValidationError extends Error {
|
||||
|
Reference in New Issue
Block a user