Fix lit linting, WIP.

This commit is contained in:
John Livingston 2024-06-12 18:51:04 +02:00
parent be93f26fb1
commit d4692c81e0
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 32 additions and 17 deletions

View File

@ -129,8 +129,8 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
<form livechat-configuration-channel-options role="form" @submit=${el.saveConfig}> <form livechat-configuration-channel-options role="form" @submit=${el.saveConfig}>
<livechat-configuration-section-header <livechat-configuration-section-header
.title=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_SLOW_MODE_LABEL)} .label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_SLOW_MODE_LABEL)}
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_SLOW_MODE_DESC, true)} .description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_SLOW_MODE_DESC)}
.helpPage=${'documentation/user/streamers/slow_mode'}> .helpPage=${'documentation/user/streamers/slow_mode'}>
</livechat-configuration-section-header> </livechat-configuration-section-header>
<div class="form-group"> <div class="form-group">
@ -164,7 +164,7 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
</div> </div>
<livechat-configuration-section-header <livechat-configuration-section-header
.title=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)} .label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)}
.description=${''} .description=${''}
.helpPage=${'documentation/user/streamers/channel'}> .helpPage=${'documentation/user/streamers/channel'}>
</livechat-configuration-section-header> </livechat-configuration-section-header>
@ -220,7 +220,7 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
</div> </div>
<livechat-configuration-section-header <livechat-configuration-section-header
.title=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL)} .label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL)}
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_DESC)} .description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_DESC)}
.helpPage=${'documentation/user/streamers/bot/forbidden_words'}> .helpPage=${'documentation/user/streamers/bot/forbidden_words'}>
</livechat-configuration-section-header> </livechat-configuration-section-header>
@ -241,7 +241,7 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
></livechat-dynamic-table-form> ></livechat-dynamic-table-form>
<livechat-configuration-section-header <livechat-configuration-section-header
.title=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL)} .label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL)}
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC)} .description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC)}
.helpPage=${'documentation/user/streamers/bot/quotes'}> .helpPage=${'documentation/user/streamers/bot/quotes'}>
</livechat-configuration-section-header> </livechat-configuration-section-header>
@ -262,7 +262,7 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
></livechat-dynamic-table-form> ></livechat-dynamic-table-form>
<livechat-configuration-section-header <livechat-configuration-section-header
.title=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_LABEL)} .label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_LABEL)}
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC)} .description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC)}
.helpPage=${'documentation/user/streamers/bot/commands'}> .helpPage=${'documentation/user/streamers/bot/commands'}>
</livechat-configuration-section-header> </livechat-configuration-section-header>

View File

@ -28,9 +28,14 @@ async function registerConfiguration (clientOptions: RegisterClientOptions): Pro
route: 'livechat/configuration/channel', route: 'livechat/configuration/channel',
onMount: async ({ rootEl }) => { onMount: async ({ rootEl }) => {
const urlParams = new URLSearchParams(window.location.search) const urlParams = new URLSearchParams(window.location.search)
const channelId = urlParams.get('channelId') ?? '' const channelId = parseInt(urlParams.get('channelId') ?? '')
render(html`<livechat-channel-configuration .registerClientOptions=${clientOptions} if (isNaN(channelId)) { throw new Error('Invalid channelId parameter') }
.channelId=${channelId}></livechat-channel-configuration>`, rootEl) render(html`
<livechat-channel-configuration
.registerClientOptions=${clientOptions}
.channelId=${channelId}></livechat-channel-configuration
></livechat-channel-configuration>
`, rootEl)
} }
}) })
@ -38,7 +43,8 @@ async function registerConfiguration (clientOptions: RegisterClientOptions): Pro
route: 'livechat/configuration/emojis', route: 'livechat/configuration/emojis',
onMount: async ({ rootEl }) => { onMount: async ({ rootEl }) => {
const urlParams = new URLSearchParams(window.location.search) const urlParams = new URLSearchParams(window.location.search)
const channelId = urlParams.get('channelId') ?? '' const channelId = parseInt(urlParams.get('channelId') ?? '')
if (isNaN(channelId)) { throw new Error('Invalid channelId parameter') }
render(html` render(html`
<livechat-channel-emojis <livechat-channel-emojis
.registerClientOptions=${clientOptions} .registerClientOptions=${clientOptions}

View File

@ -1,7 +1,9 @@
// SPDX-FileCopyrightText: 2024 Mehdi Benadel <https://mehdibenadel.com> // SPDX-FileCopyrightText: 2024 Mehdi Benadel <https://mehdibenadel.com>
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
// //
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import { ptTr } from '../directives/translation'
import { html } from 'lit' import { html } from 'lit'
import { customElement, property } from 'lit/decorators.js' import { customElement, property } from 'lit/decorators.js'
import { LivechatElement } from './livechat' import { LivechatElement } from './livechat'
@ -9,21 +11,28 @@ import { LivechatElement } from './livechat'
@customElement('livechat-configuration-section-header') @customElement('livechat-configuration-section-header')
export class ConfigurationSectionHeaderElement extends LivechatElement { export class ConfigurationSectionHeaderElement extends LivechatElement {
@property({ attribute: false }) @property({ attribute: false })
public override title: string = 'title' public label: string | ReturnType<typeof ptTr> = '???'
@property({ attribute: false }) @property({ attribute: false })
public description: string = 'Here\'s a description' public description?: string | ReturnType<typeof ptTr>
@property({ attribute: false }) @property({ attribute: false })
public helpPage: string = 'documentation' public helpPage?: string
protected override render = (): unknown => { protected override render = (): unknown => {
return html` return html`
<h2> <h2>
${this.title} ${this.label}
<livechat-help-button .page=${this.helpPage}></livechat-help-button> ${
this.helpPage === undefined
? ''
: html`<livechat-help-button .page=${this.helpPage}></livechat-help-button>`
}
</h2> </h2>
<p>${this.description}</p> ${
` this.description === undefined
? ''
: html`<p>${this.description}</p>`
}`
} }
} }