Merge pull request #516 from Nohan-V2/main
Handle NaN in numeric settings parsing
This commit is contained in:
commit
3d36093abb
2 changed files with 10 additions and 5 deletions
|
|
@ -1137,7 +1137,8 @@ export async function initializeSettings(scrobbler, player, api, ui) {
|
|||
if (replayGainPreamp) {
|
||||
replayGainPreamp.value = replayGainSettings.getPreamp();
|
||||
replayGainPreamp.addEventListener('change', (e) => {
|
||||
replayGainSettings.setPreamp(parseFloat(e.target.value) || 3);
|
||||
const val = parseFloat(e.target.value);
|
||||
replayGainSettings.setPreamp(isNaN(val) ? 3 : val);
|
||||
player.applyReplayGain();
|
||||
});
|
||||
}
|
||||
|
|
@ -1174,7 +1175,8 @@ export async function initializeSettings(scrobbler, player, api, ui) {
|
|||
if (playbackSpeedSlider && playbackSpeedInput) {
|
||||
// Helper function to update both controls
|
||||
const updatePlaybackSpeedControls = (speed) => {
|
||||
const validSpeed = Math.max(0.01, Math.min(100, parseFloat(speed) || 1.0));
|
||||
const parsedSpeed = parseFloat(speed);
|
||||
const validSpeed = Math.max(0.01, Math.min(100, isNaN(parsedSpeed) ? 1.0 : parsedSpeed));
|
||||
playbackSpeedInput.value = validSpeed;
|
||||
// Only update slider if value is within slider range
|
||||
if (validSpeed >= 0.25 && validSpeed <= 4.0) {
|
||||
|
|
|
|||
|
|
@ -442,7 +442,8 @@ export const lastFMStorage = {
|
|||
},
|
||||
|
||||
setScrobblePercentage(percentage) {
|
||||
const validPercentage = Math.max(1, Math.min(100, parseInt(percentage, 10) || 75));
|
||||
const parsed = parseInt(percentage, 10);
|
||||
const validPercentage = Math.max(1, Math.min(100, isNaN(parsed) ? 75 : parsed));
|
||||
localStorage.setItem(this.SCROBBLE_PERCENTAGE_KEY, validPercentage.toString());
|
||||
},
|
||||
|
||||
|
|
@ -1123,9 +1124,10 @@ export const equalizerSettings = {
|
|||
},
|
||||
|
||||
setBandCount(count) {
|
||||
const parsedCount = parseInt(count, 10);
|
||||
const validCount = Math.max(
|
||||
this.MIN_BANDS,
|
||||
Math.min(this.MAX_BANDS, parseInt(count, 10) || this.DEFAULT_BAND_COUNT)
|
||||
Math.min(this.MAX_BANDS, isNaN(parsedCount) ? this.DEFAULT_BAND_COUNT : parsedCount)
|
||||
);
|
||||
localStorage.setItem(this.BAND_COUNT_KEY, validCount.toString());
|
||||
},
|
||||
|
|
@ -2451,7 +2453,8 @@ export const fontSettings = {
|
|||
},
|
||||
|
||||
setFontSize(size) {
|
||||
const validSize = Math.max(50, Math.min(200, parseInt(size, 10) || 100));
|
||||
const parsed = parseInt(size, 10);
|
||||
const validSize = Math.max(50, Math.min(200, isNaN(parsed) ? 100 : parsed));
|
||||
localStorage.setItem(this.FONT_SIZE_KEY, validSize.toString());
|
||||
this.applyFontSize();
|
||||
return validSize;
|
||||
|
|
|
|||
Loading…
Reference in a new issue