Skip to content

Commit

Permalink
fix speed computation
Browse files Browse the repository at this point in the history
  • Loading branch information
GooseOb committed Dec 8, 2024
1 parent 24e9cb9 commit 1f745b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
23 changes: 16 additions & 7 deletions src/compute-settings.ts
Original file line number Diff line number Diff line change
@@ -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;
};

0 comments on commit 1f745b4

Please sign in to comment.