From 60ea2b4ed08636a8646dc91e82f6fc8a5e23d4aa Mon Sep 17 00:00:00 2001 From: John Livingston Date: Wed, 21 May 2025 17:51:54 +0200 Subject: [PATCH] Fix #626: Bot timer was buggy, using seconds as delay instead of minutes. There was a regression some months ago in the "bot timer" functionnality. In the channels settings, the delay between two quotes is supposed to be in minutes, but in fact we applied seconds. We don't have any way to detect if the user meant seconds or minutes when they configured their channels (it depends if it was before or after the regression). So we encourage all streamers to go through their channel settings, check the frequency of their bot timers (if enabled), set them to the correct value, and save the form. Users must save the form to be sure to apply the correct value. --- CHANGELOG.md | 11 ++++++- .../configuration/services/channel-details.ts | 29 +++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d0d4d50..f6ce00cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Changelog -## ??? (Not Released Yet) +## 13.0.0 (Not Released Yet) + +### Breaking changes + +There was a regression some months ago in the "bot timer" functionnality. +In the channels settings, the delay between two quotes is supposed to be in minutes, but in fact we applied seconds. +We don't have any way to detect if the user meant seconds or minutes when they configured their channels (it depends if it was before or after the regression). +So we encourage all streamers to go through their channel settings, check the frequency of their bot timers (if enabled), set them to the correct value, and save the form. +Users must save the form to be sure to apply the correct value. ### Minor changes and fixes @@ -16,6 +24,7 @@ * Fix moderation notes: fix filter button wrongly displayed on notes without associated occupant. * Fix tasks: checkbox state does not change when clicked. * Fix: bot timer can't be negative or null. +* Fix #626: Bot timer was buggy, using seconds as delay instead of minutes. ## 12.0.4 diff --git a/client/common/configuration/services/channel-details.ts b/client/common/configuration/services/channel-details.ts index 39ba7a6b..2665bd40 100644 --- a/client/common/configuration/services/channel-details.ts +++ b/client/common/configuration/services/channel-details.ts @@ -151,6 +151,29 @@ export class ChannelDetailsService { return true } + frontToBack = (channelConfigurationOptions: ChannelConfigurationOptions): ChannelConfigurationOptions => { + // // This is a dirty hack, because backend wants seconds for botConf.quotes.delay, and front wants minutes. + const c = JSON.parse(JSON.stringify(channelConfigurationOptions)) as ChannelConfigurationOptions // clone + c.bot?.quotes.forEach(q => { + if (typeof q.delay === 'number') { + q.delay = Math.round(q.delay * 60) + } + }) + return c + } + + backToFront = (channelConfiguration: any): ChannelConfiguration => { + // This is a dirty hack, because backend wants seconds for botConf.quotes.delay, and front wants minutes. + const c = JSON.parse(JSON.stringify(channelConfiguration)) as ChannelConfiguration // clone + c.configuration.bot?.quotes.forEach(q => { + if (typeof q.delay === 'number') { + q.delay = Math.round(q.delay / 60) + if (q.delay < 1) { q.delay = 1 } + } + }) + return c + } + saveOptions = async (channelId: number, channelConfigurationOptions: ChannelConfigurationOptions): Promise => { if (!await this.validateOptions(channelConfigurationOptions)) { @@ -162,7 +185,9 @@ export class ChannelDetailsService { { method: 'POST', headers: this._headers, - body: JSON.stringify(channelConfigurationOptions) + body: JSON.stringify( + this.frontToBack(channelConfigurationOptions) + ) } ) @@ -218,7 +243,7 @@ export class ChannelDetailsService { throw new Error('Can\'t get channel configuration options.') } - return response.json() + return this.backToFront(await response.json()) } public async fetchEmojisConfiguration (channelId: number): Promise {