Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: left menu not updated #282

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/js/components/package/pannels/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Warnings {
const { warnings } = this.package.dependencyVersion;
this.package.addNavigationSignal(
clone.getElementById("warnings-nav-menu"),
warnings.filter((warning) => !window.settings.warnings.has(warning.kind)).length
warnings.filter((warning) => !window.settings.config.ignore.warnings.has(warning.kind)).length
);
}

Expand All @@ -52,7 +52,7 @@ export class Warnings {
const codeFetcher = new UnpkgCodeFetcher(unpkgRoot);

for (const warning of warnings) {
if (window.settings.warnings.has(warning.kind)) {
if (window.settings.config.ignore.warnings.has(warning.kind)) {
continue;
}

Expand Down
11 changes: 8 additions & 3 deletions public/js/components/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export class Settings {
this.config = config;
this.warnings = new Set(this.config.ignore.warnings);
this.flags = new Set(this.config.ignore.flags);
this.config.ignore.warnings = this.warnings;
this.config.ignore.flags = this.flags;
}

async fetchUserConfig() {
Expand All @@ -52,21 +54,24 @@ export class Settings {

const newConfig = {
defaultPackageMenu: this.dom.defaultPackageMenu.value || Settings.defaultMenuName,
ignore: { flags: [], warnings: [] }
ignore: { flags: new Set(), warnings: new Set() }
};

for (const checkbox of this.dom.warningsCheckbox) {
if (checkbox.checked) {
newConfig.ignore.warnings.push(checkbox.getAttribute("value"));
newConfig.ignore.warnings.add(checkbox.getAttribute("value"));
}
}

for (const checkbox of this.dom.flagsCheckbox) {
if (checkbox.checked) {
newConfig.ignore.flags.push(checkbox.getAttribute("value"));
newConfig.ignore.flags.add(checkbox.getAttribute("value"));
}
}

newConfig.ignore.warnings = [...newConfig.ignore.warnings];
newConfig.ignore.flags = [...newConfig.ignore.flags];

await fetch("/config", {
method: "put",
body: JSON.stringify(newConfig),
Expand Down
8 changes: 6 additions & 2 deletions public/js/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ document.addEventListener("DOMContentLoaded", async () => {
nsn.network.on("click", updateShowInfoMenu);

window.addEventListener("settings-saved", async (event) => {
secureDataSet.warningsToIgnore = new Set(event.detail.ignore.warnings);
secureDataSet.flagsToIgnore = new Set(event.detail.ignore.flags);
const warningsToIgnore = new Set(event.detail.ignore.warnings);
const flagsToIgnore = new Set(event.detail.ignore.flags);
secureDataSet.warningsToIgnore = warningsToIgnore;
secureDataSet.flagsToIgnore = flagsToIgnore;
window.settings.config.ignore.warnings = warningsToIgnore;
window.settings.config.ignore.flags = flagsToIgnore;

await secureDataSet.init(secureDataSet.data);
const { nodes } = secureDataSet.build();
Expand Down
Loading