fixed tags not showing up in the account page filters

This commit is contained in:
Miodec 2023-01-29 01:01:08 +01:00
parent 26a19a87b0
commit 0d2af80a80
3 changed files with 25 additions and 32 deletions

View file

@ -458,32 +458,6 @@ export function toggle<G extends MonkeyTypes.Group>(
}
}
export function updateTags(): void {
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).empty();
const snapshot = DB.getSnapshot();
if ((snapshot?.tags?.length ?? 0) > 0) {
$(".pageAccount .content .filterButtons .buttonsAndTitle.tags").removeClass(
"hidden"
);
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).append(`<div class="button" filter="none">no tag</div>`);
snapshot?.tags?.forEach((tag) => {
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).append(`<div class="button" filter="${tag._id}">${tag.display}</div>`);
});
} else {
$(".pageAccount .content .filterButtons .buttonsAndTitle.tags").addClass(
"hidden"
);
}
}
$(
".pageAccount .filterButtons .buttonsAndTitle .buttons, .pageAccount .group.topFilters .buttonsAndTitle.testDate .buttons"
).on("click", ".button", (e) => {
@ -722,6 +696,28 @@ export async function appendButtons(): Promise<void> {
el.innerHTML = `<div class="button" filter="none">none</div>` + html;
}
}
const snapshot = DB.getSnapshot();
if ((snapshot?.tags?.length ?? 0) > 0) {
$(".pageAccount .content .filterButtons .buttonsAndTitle.tags").removeClass(
"hidden"
);
let html = `<div class="button" filter="none">no tag</div>`;
for (const tag of snapshot?.tags ?? []) {
html += `<div class="button" filter="${tag._id}">${tag.display}</div>`;
}
const el = document.querySelector(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
);
if (el) {
el.innerHTML = html;
}
} else {
$(".pageAccount .content .filterButtons .buttonsAndTitle.tags").addClass(
"hidden"
);
}
}
export function removeButtons(): void {
@ -731,6 +727,9 @@ export function removeButtons(): void {
$(
".pageAccount .content .filterButtons .buttonsAndTitle.funbox .buttons"
).empty();
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).empty();
}
$(".pageAccount .topFilters .button.createFilterPresetBtn").on("click", () => {

View file

@ -224,7 +224,6 @@ export async function getDataAndInit(): Promise<boolean> {
}
}
AccountButton.loading(false);
ResultFilters.updateTags();
updateTagsCommands();
TagController.loadActiveFromLocalStorage();
Settings.showAccountSection();

View file

@ -1,5 +1,4 @@
import Ape from "../ape";
import * as ResultFilters from "../account/result-filters";
import * as DB from "../db";
import * as Notifications from "../elements/notifications";
import * as Loader from "../elements/loader";
@ -102,7 +101,6 @@ async function apply(): Promise<void> {
_id: response.data._id,
});
Settings.update();
ResultFilters.updateTags();
}
} else if (action === "edit") {
const response = await Ape.users.editTag(tagId, tagName);
@ -118,7 +116,6 @@ async function apply(): Promise<void> {
}
});
Settings.update();
ResultFilters.updateTags();
}
} else if (action === "remove") {
const response = await Ape.users.deleteTag(tagId);
@ -133,7 +130,6 @@ async function apply(): Promise<void> {
}
});
Settings.update();
ResultFilters.updateTags();
}
} else if (action === "clearPb") {
const response = await Ape.users.deleteTagPersonalBest(tagId);
@ -154,7 +150,6 @@ async function apply(): Promise<void> {
}
});
Settings.update();
ResultFilters.updateTags();
}
}
Loader.hide();