diff --git a/CHANGELOG.md b/CHANGELOG.md index ef754363..d3ec67c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/client/common/configuration/elements/channel-emojis.ts b/client/common/configuration/elements/channel-emojis.ts index 5848c62e..4e754e00 100644 --- a/client/common/configuration/elements/channel-emojis.ts +++ b/client/common/configuration/elements/channel-emojis.ts @@ -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')