Refactoring: simplifing the peertube context.
This commit is contained in:
@ -2,12 +2,9 @@
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||
import { LivechatElement } from './livechat'
|
||||
import { registerClientOptionsContext } from '../contexts/peertube'
|
||||
import { html } from 'lit'
|
||||
import { customElement, property } from 'lit/decorators.js'
|
||||
import { consume } from '@lit/context'
|
||||
|
||||
/**
|
||||
* Special element to upload image files.
|
||||
@ -23,9 +20,6 @@ import { consume } from '@lit/context'
|
||||
*/
|
||||
@customElement('livechat-image-file-input')
|
||||
export class ImageFileInputElement extends LivechatElement {
|
||||
@consume({ context: registerClientOptionsContext, subscribe: true })
|
||||
public registerClientOptions?: RegisterClientOptions
|
||||
|
||||
@property({ attribute: false })
|
||||
public name?: string
|
||||
|
||||
@ -68,11 +62,11 @@ export class ImageFileInputElement extends LivechatElement {
|
||||
}
|
||||
|
||||
if (this.maxSize && file.size > this.maxSize) {
|
||||
let msg = await this.registerClientOptions?.peertubeHelpers.translate(LOC_INVALID_VALUE_FILE_TOO_BIG)
|
||||
let msg = await this.ptTranslate(LOC_INVALID_VALUE_FILE_TOO_BIG)
|
||||
if (msg) {
|
||||
// FIXME: better unit handling (here we force kb)
|
||||
msg = msg.replace('%s', Math.round(this.maxSize / 1024).toString() + 'k')
|
||||
this.registerClientOptions?.peertubeHelpers.notifier.error(msg)
|
||||
this.ptNotifier.error(msg)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user