Fix #437: removing last line if empty when importing emojis.

This commit is contained in:
John Livingston 2024-06-20 11:45:36 +02:00
parent a0b4b5f61a
commit 48905dd70d
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
2 changed files with 11 additions and 1 deletions

View File

@ -2,8 +2,9 @@
## 10.1.1 (Not released yet)
* #436: Saving emojis per batch, to avoid hitting max payload limit.
* Fix #436: Saving emojis per batch, to avoid hitting max payload limit.
* Fix: the emojis import function could add more entries than max allowed emoji count.
* Fix #437: removing last line if empty when importing emojis.
## 10.1.0

View File

@ -174,6 +174,15 @@ export class ChannelEmojisElement extends LivechatElement {
if (!Array.isArray(json)) {
throw new Error('Invalid data, an array was expected')
}
// Before adding new entries, we check if the last current line is empty,
// and remove it in such case.
// See https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/437
const last = this.channelEmojisConfiguration?.emojis.customEmojis.slice(-1)[0]
if (last && last.sn === '' && last.url === '') {
this.channelEmojisConfiguration?.emojis.customEmojis.pop()
}
for (const entry of json) {
if (typeof entry !== 'object') {
throw new Error('Invalid data')