Skip to content

Commit

Permalink
fix: Environment error in filters and fixed NaN time
Browse files Browse the repository at this point in the history
  • Loading branch information
richardscull committed Sep 9, 2023
1 parent de593eb commit ea082f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/menu/setFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ async function changeSettingInput(
const localizationSettings = await localization.get("settings");
const localizationSetSettings = await localization.get("setSettings");

const filters = config.get("filters") ? config.get("filters") : {};
const filter = filters[name] ? filters[name] : {};

await inquirer
.prompt([
{
Expand All @@ -88,6 +85,9 @@ async function changeSettingInput(
});

async function enterValue(multipleVal: boolean) {
const filters = config.get("filters") ? config.get("filters") : {};
const filter = filters[name] ? filters[name] : {};

let timesToEnter = multipleVal ? 2 : 1;
for (timesToEnter; timesToEnter > 0; timesToEnter--) {
const enterNumVal = `${localizationSettings.change} ${
Expand All @@ -113,12 +113,12 @@ async function changeSettingInput(
} else {
filter[attr] = options.value || undefined;
}

config.set("filters", {
...filters,
[name]: filter,
});
});

config.set("filters", {
...filters,
[name]: filter,
});
}
}
}
8 changes: 6 additions & 2 deletions src/menu/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export default async function toSettings(config: Jsoning) {
});
}

function toTimeIfNumber(value: number) {
return isNaN(value) ? undefined : msToMinAndSec(value * 1000);
}

async function showCurrentSettings(config: Jsoning) {
const localization = await getLocalizationJson(config);
const localizationSettings = await localization.get("settings");
Expand Down Expand Up @@ -124,8 +128,8 @@ async function showFilters(config: Jsoning, name: "local" | "chimu") {
if (filter.lengthMin || filter.lengthMax)
console.log(
`${localizationFilter.length}: ${
msToMinAndSec(filter.lengthMin * 1000) || "0"
}${msToMinAndSec(filter.lengthMax * 1000) || "∞"} ⌛`
toTimeIfNumber(filter.lengthMin) || "0"
}${toTimeIfNumber(filter.lengthMax) || "∞"} ⌛`
);
if (filter.genre) console.log(`${localizationFilter.genre}: ${filter.genre}`);

Expand Down

0 comments on commit ea082f8

Please sign in to comment.