From fb7f44692c2c98ffedba335fd18cb8b0af974fed Mon Sep 17 00:00:00 2001 From: Mehdi Benadel Date: Thu, 23 May 2024 22:52:39 +0200 Subject: [PATCH] fix linting --- .../common/configuration/contexts/channel.ts | 6 +- .../elements/channel-configuration.ts | 96 +++---- .../configuration/elements/channel-home.ts | 25 +- .../elements/configuration-row.ts | 9 +- .../configuration/services/channel-details.ts | 22 +- client/common/lib/contexts/peertube.ts | 3 +- client/common/lib/directives/translation.ts | 74 +++--- .../common/lib/elements/dynamic-table-form.ts | 236 ++++++++++++------ client/common/lib/elements/help-button.ts | 13 +- client/common/lib/elements/livechat.ts | 2 +- 10 files changed, 282 insertions(+), 204 deletions(-) diff --git a/client/common/configuration/contexts/channel.ts b/client/common/configuration/contexts/channel.ts index 09b2a606..ee41dc55 100644 --- a/client/common/configuration/contexts/channel.ts +++ b/client/common/configuration/contexts/channel.ts @@ -6,5 +6,7 @@ import type { ChannelConfiguration } from 'shared/lib/types' import { createContext } from '@lit/context' import { ChannelDetailsService } from '../services/channel-details' -export const channelConfigurationContext = createContext(Symbol('channel-configuration')) -export const channelDetailsServiceContext = createContext(Symbol('channel-configuration-service')) +export const channelConfigurationContext = + createContext(Symbol('channel-configuration')) +export const channelDetailsServiceContext = + createContext(Symbol('channel-configuration-service')) diff --git a/client/common/configuration/elements/channel-configuration.ts b/client/common/configuration/elements/channel-configuration.ts index 5f7706dd..46c92b87 100644 --- a/client/common/configuration/elements/channel-configuration.ts +++ b/client/common/configuration/elements/channel-configuration.ts @@ -16,7 +16,6 @@ import { LivechatElement } from '../../lib/elements/livechat' @customElement('livechat-channel-configuration') export class ChannelConfigurationElement extends LivechatElement { - @provide({ context: registerClientOptionsContext }) @property({ attribute: false }) public registerClientOptions: RegisterClientOptions | undefined @@ -34,38 +33,36 @@ export class ChannelConfigurationElement extends LivechatElement { @state() public _formStatus: boolean | any = undefined - private _asyncTaskRender = new Task(this, { - - task: async ([registerClientOptions], { signal }) => { - if (this.registerClientOptions) { - this._channelDetailsService = new ChannelDetailsService(this.registerClientOptions) + private readonly _asyncTaskRender = new Task(this, { + task: async ([registerClientOptions]) => { + if (registerClientOptions) { + this._channelDetailsService = new ChannelDetailsService(registerClientOptions) this._channelConfiguration = await this._channelDetailsService.fetchConfiguration(this.channelId ?? 0) } }, - args: () => [this.registerClientOptions] + }) - }); - - private _saveConfig = (ev?: Event) => { + private readonly _saveConfig = (ev?: Event): undefined => { ev?.preventDefault() if (this._channelDetailsService && this._channelConfiguration) { - this._channelDetailsService.saveOptions(this._channelConfiguration.channel.id, this._channelConfiguration.configuration) - .then((value) => { + this._channelDetailsService.saveOptions(this._channelConfiguration.channel.id, + this._channelConfiguration.configuration) + .then(() => { this._formStatus = { success: true } - console.log(`Configuration has been updated`) + console.log('Configuration has been updated') this.requestUpdate('_formStatus') }) .catch((error) => { this._formStatus = error console.log(`An error occurred : ${JSON.stringify(this._formStatus)}`) this.requestUpdate('_formStatus') - }); + }) } } - render = () => { - let tableHeaderList = { + protected override render = (): unknown => { + const tableHeaderList = { forbiddenWords: { entries: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL), @@ -113,16 +110,16 @@ export class ChannelConfigurationElement extends LivechatElement { } } } - let tableSchema = { + const tableSchema = { forbiddenWords: { entries: { inputType: 'textarea', default: [''], - separator: '\n', + separator: '\n' }, regex: { inputType: 'checkbox', - default: false, + default: false }, applyToModerators: { inputType: 'checkbox', @@ -140,34 +137,35 @@ export class ChannelConfigurationElement extends LivechatElement { comments: { inputType: 'textarea', default: '' - }, + } }, quotes: { messages: { inputType: 'textarea', default: [''], - separator: '\n', + separator: '\n' }, delay: { inputType: 'number', - default: 10, + default: 10 } }, commands: { command: { inputType: 'text', - default: '', + default: '' }, message: { inputType: 'text', - default: '', + default: '' } } } return this._asyncTaskRender.render({ complete: () => html` -
+

${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_TITLE)}: @@ -185,7 +183,7 @@ export class ChannelConfigurationElement extends LivechatElement { + .helpPage=${'documentation/user/streamers/slow_mode'}>

@@ -199,8 +197,10 @@ export class ChannelConfigurationElement extends LivechatElement { max="1000" id="peertube-livechat-slow-mode-duration" @input=${(event: InputEvent) => { - if (event?.target && this._channelConfiguration) - this._channelConfiguration.configuration.slowMode.duration = Number((event.target as HTMLInputElement).value) + if (event?.target && this._channelConfiguration) { + this._channelConfiguration.configuration.slowMode.duration = + Number((event.target as HTMLInputElement).value) + } this.requestUpdate('_channelConfiguration') } } @@ -215,7 +215,7 @@ export class ChannelConfigurationElement extends LivechatElement { + .helpPage=${'documentation/user/streamers/channel'}>
@@ -226,8 +226,10 @@ export class ChannelConfigurationElement extends LivechatElement { name="bot" id="peertube-livechat-bot" @input=${(event: InputEvent) => { - if (event?.target && this._channelConfiguration) - this._channelConfiguration.configuration.bot.enabled = (event.target as HTMLInputElement).checked + if (event?.target && this._channelConfiguration) { + this._channelConfiguration.configuration.bot.enabled = + (event.target as HTMLInputElement).checked + } this.requestUpdate('_channelConfiguration') } } @@ -237,17 +239,21 @@ export class ChannelConfigurationElement extends LivechatElement { ${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_ENABLE_BOT_LABEL)}
- ${this._channelConfiguration?.configuration.bot.enabled ? - html`
- + ${this._channelConfiguration?.configuration.bot.enabled + ? html`
+ + ${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_NICKNAME)} + { - if (event?.target && this._channelConfiguration) - this._channelConfiguration.configuration.bot.nickname = (event.target as HTMLInputElement).value + if (event?.target && this._channelConfiguration) { + this._channelConfiguration.configuration.bot.nickname = + (event.target as HTMLInputElement).value + } this.requestUpdate('_channelConfiguration') } } @@ -258,13 +264,13 @@ export class ChannelConfigurationElement extends LivechatElement { }
- ${this._channelConfiguration?.configuration.bot.enabled ? - html`
+ ${this._channelConfiguration?.configuration.bot.enabled + ? html`
+ .helpPage=${'documentation/user/streamers/bot/forbidden_words'}>
@@ -288,7 +294,7 @@ export class ChannelConfigurationElement extends LivechatElement { + .helpPage=${'documentation/user/streamers/bot/quotes'}>
@@ -312,7 +318,7 @@ export class ChannelConfigurationElement extends LivechatElement { + .helpPage=${'documentation/user/streamers/bot/commands'}>
@@ -336,14 +342,14 @@ export class ChannelConfigurationElement extends LivechatElement {
- ${(this._formStatus && this._formStatus.success === undefined) ? - html`