Emoji only mode WIP:
* Button to enable it on all rooms.
This commit is contained in:
@ -256,6 +256,21 @@ export class ChannelEmojisElement extends LivechatElement {
|
||||
}
|
||||
}
|
||||
|
||||
public async enableEmojisOnlyModeOnAllRooms (ev: Event): Promise<void> {
|
||||
ev.preventDefault()
|
||||
if (!this._channelDetailsService || !this.channelId) {
|
||||
this.ptNotifier.error(await this.ptTranslate(LOC_ERROR))
|
||||
return
|
||||
}
|
||||
try {
|
||||
await this._channelDetailsService.enableEmojisOnlyModeOnAllRooms(this.channelId)
|
||||
this.ptNotifier.info(await this.ptTranslate(LOC_SUCCESSFULLY_SAVED))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
this.ptNotifier.error(await this.ptTranslate(LOC_ERROR))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an url (or dataUrl), download the image, and converts to dataUrl.
|
||||
* @param url the url
|
||||
|
@ -45,13 +45,14 @@ export function tplChannelEmojis (el: ChannelEmojisElement): TemplateResult {
|
||||
|
||||
<livechat-channel-tabs .active=${'emojis'} .channelId=${el.channelId}></livechat-channel-tabs>
|
||||
|
||||
<h2>${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_EMOJIS_TITLE)}</h2>
|
||||
|
||||
<p>
|
||||
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_EMOJIS_DESC)}
|
||||
<livechat-help-button .page=${'documentation/user/streamers/emojis'}>
|
||||
</livechat-help-button>
|
||||
</p>
|
||||
|
||||
|
||||
<form role="form" @submit=${el.saveEmojis} @change=${el.resetValidation}>
|
||||
<div class="peertube-plugin-livechat-configuration-actions">
|
||||
${
|
||||
@ -106,5 +107,23 @@ export function tplChannelEmojis (el: ChannelEmojisElement): TemplateResult {
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h2>${ptTr(LOC_EMOJI_ONLY_MODE_TITLE)}</h2>
|
||||
|
||||
<p>
|
||||
${ptTr(LOC_EMOJI_ONLY_MODE_DESC_1, true)}
|
||||
</p>
|
||||
<p>
|
||||
${ptTr(LOC_EMOJI_ONLY_MODE_DESC_2, true)}
|
||||
</p>
|
||||
<p>
|
||||
${ptTr(LOC_EMOJI_ONLY_MODE_DESC_3, true)}
|
||||
</p>
|
||||
|
||||
<div class="peertube-plugin-livechat-configuration-actions">
|
||||
<button type="button" @click=${el.enableEmojisOnlyModeOnAllRooms}>
|
||||
${ptTr(LOC_EMOJI_ONLY_ENABLE_ALL_ROOMS)}
|
||||
</button>
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
@ -312,4 +312,23 @@ export class ChannelDetailsService {
|
||||
|
||||
return response.json()
|
||||
}
|
||||
|
||||
public async enableEmojisOnlyModeOnAllRooms (channelId: number): Promise<void> {
|
||||
const response = await fetch(
|
||||
getBaseRoute(this._registerClientOptions) +
|
||||
'/api/configuration/channel/emojis/' +
|
||||
encodeURIComponent(channelId) +
|
||||
'/enable_emoji_only',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: this._headers
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Can\'t enable Emojis Only Mode on all rooms.')
|
||||
}
|
||||
|
||||
return response.json()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user