Refactoring: simplifing the peertube context.

This commit is contained in:
John Livingston
2024-06-12 16:26:35 +02:00
parent 268c60d699
commit 2c3739f633
13 changed files with 73 additions and 157 deletions

View File

@ -5,8 +5,6 @@
import type { TagsInputElement } from './tags-input'
import type { DirectiveResult } from 'lit/directive'
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
import { registerClientOptionsContext } from '../../lib/contexts/peertube'
import { ValidationErrorType } from '../models/validation'
import { maxSize, inputFileAccept } from 'shared/lib/emojis'
import { html, nothing, TemplateResult } from 'lit'
@ -17,7 +15,6 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'
import { classMap } from 'lit/directives/class-map.js'
import { LivechatElement } from './livechat'
import { ptTr } from '../directives/translation'
import { consume } from '@lit/context'
// This content comes from the file assets/images/plus-square.svg, from the Feather icons set https://feathericons.com/
const AddSVG: string =
@ -95,9 +92,6 @@ export interface DynamicFormSchema { [key: string]: CellDataSchema }
@customElement('livechat-dynamic-table-form')
export class DynamicTableFormElement extends LivechatElement {
@consume({ context: registerClientOptionsContext, subscribe: true })
public registerClientOptions?: RegisterClientOptions
@property({ attribute: false })
public header: DynamicFormHeader = {}
@ -162,14 +156,9 @@ export class DynamicTableFormElement extends LivechatElement {
}
private async _removeRow (rowId: number): Promise<void> {
if (!this.registerClientOptions) {
console.error('Missing registreClientOptions.')
return
}
const peertubeHelpers = this.registerClientOptions.peertubeHelpers
const confirmMsg = await peertubeHelpers.translate(LOC_ACTION_REMOVE_ENTRY_CONFIRM)
const confirmMsg = await this.ptTranslate(LOC_ACTION_REMOVE_ENTRY_CONFIRM)
await new Promise<void>((resolve, reject) => {
peertubeHelpers.showModal({
this.ptOptions.peertubeHelpers.showModal({
title: confirmMsg,
content: '',
close: true,