From 1f745b497cb533325352d04a0f61f72e4f8d3aba Mon Sep 17 00:00:00 2001 From: GooseOb Date: Sun, 8 Dec 2024 04:14:46 +0100 Subject: [PATCH] fix speed computation --- package.json | 2 +- src/compute-settings.ts | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 303be46..182ebc0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yt-defaulter", "author": "GooseOb", - "version": "1.11.4", + "version": "1.11.5", "repository": { "type": "git", "url": "git+https://github.com/GooseOb/YT-Defaulter.git" diff --git a/src/compute-settings.ts b/src/compute-settings.ts index 6934e05..9463a99 100644 --- a/src/compute-settings.ts +++ b/src/compute-settings.ts @@ -1,20 +1,29 @@ import * as config from './config'; import { plr } from './player'; -export const computeSettings = (doNotChangeSpeed: boolean): Cfg => { +/** + * Priority of speed settings: + * 0. Use normal speed + * 1. Channel custom speed + * 2. Channel speed + * 3. Global custom speed + * 4. Global speed + */ +export const computeSettings = (doUseNormalSpeed: boolean): Cfg => { + const channel = config.channel.get(); const settings = { ...config.value.global, - ...config.channel.get(), + ...channel, }; - const isChannelSpeed = 'speed' in config.channel.get(); - const isChannelCustomSpeed = 'customSpeed' in config.channel.get(); - if (doNotChangeSpeed) { + if (doUseNormalSpeed) { settings.speed = plr.speedNormal; delete settings.customSpeed; - } else if (isChannelCustomSpeed) { + } else if ('customSpeed' in channel) { delete settings.speed; - } else if (isChannelSpeed) { + } else if ('speed' in channel) { delete settings.customSpeed; + } else if ('customSpeed' in settings) { + delete settings.speed; } return settings; };