diff --git a/frontend/src/ts/account/result-filters.ts b/frontend/src/ts/account/result-filters.ts index a16260fab..b06971ef9 100644 --- a/frontend/src/ts/account/result-filters.ts +++ b/frontend/src/ts/account/result-filters.ts @@ -458,32 +458,6 @@ export function toggle( } } -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(`
no tag
`); - snapshot?.tags?.forEach((tag) => { - $( - ".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons" - ).append(`
${tag.display}
`); - }); - } 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 { el.innerHTML = `
none
` + html; } } + + const snapshot = DB.getSnapshot(); + + if ((snapshot?.tags?.length ?? 0) > 0) { + $(".pageAccount .content .filterButtons .buttonsAndTitle.tags").removeClass( + "hidden" + ); + let html = `
no tag
`; + for (const tag of snapshot?.tags ?? []) { + html += `
${tag.display}
`; + } + 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", () => { diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index 26788d9c0..a73bf5ace 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -224,7 +224,6 @@ export async function getDataAndInit(): Promise { } } AccountButton.loading(false); - ResultFilters.updateTags(); updateTagsCommands(); TagController.loadActiveFromLocalStorage(); Settings.showAccountSection(); diff --git a/frontend/src/ts/popups/edit-tags-popup.ts b/frontend/src/ts/popups/edit-tags-popup.ts index bb4ef706c..49eddc202 100644 --- a/frontend/src/ts/popups/edit-tags-popup.ts +++ b/frontend/src/ts/popups/edit-tags-popup.ts @@ -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 { _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 { } }); Settings.update(); - ResultFilters.updateTags(); } } else if (action === "remove") { const response = await Ape.users.deleteTag(tagId); @@ -133,7 +130,6 @@ async function apply(): Promise { } }); Settings.update(); - ResultFilters.updateTags(); } } else if (action === "clearPb") { const response = await Ape.users.deleteTagPersonalBest(tagId); @@ -154,7 +150,6 @@ async function apply(): Promise { } }); Settings.update(); - ResultFilters.updateTags(); } } Loader.hide();