Skip to content

Commit

Permalink
Fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SebiWrn committed Dec 7, 2023
1 parent b7174b0 commit e7523a0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions web/ts/user-settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StatusCodes } from "http-status-codes";
import Alpine from 'alpinejs';
import Alpine from "alpinejs";

const settingsAPIBaseURL = "/api/users/settings";

Expand All @@ -8,7 +8,6 @@ export enum UserSetting {
Greeting = "greeting",
PlaybackSpeeds = "playbackSpeeds",
CustomSpeeds = "customSpeeds",

}

export function updatePreference(t: UserSetting, value: string | boolean | number[]): Promise<string> {
Expand All @@ -27,17 +26,16 @@ export function updatePreference(t: UserSetting, value: string | boolean | numbe
});
}

export function sanitizeInputSpeed(value: number) : number {
export function sanitizeInputSpeed(value: number): number {
if (value > 5) {
return 5;
} else if (value <= 0) {
return 0.01;
}
return Math.round((value) * 100) / 100
return Math.round(value * 100) / 100;
}

export function checkInputSpeed(value: number, currentSpeeds: number[]) {
const defaultSpeeds = [.25, .5, .75, 1, 1.5, 1.5, 1.75, 2, 2.5, 3, 3.5];
return (!defaultSpeeds.includes(value)) && (!currentSpeeds.includes(value));

}
const defaultSpeeds = [0.25, 0.5, 0.75, 1, 1.5, 1.5, 1.75, 2, 2.5, 3, 3.5];
return !defaultSpeeds.includes(value) && !currentSpeeds.includes(value);
}

0 comments on commit e7523a0

Please sign in to comment.