From 60766bb67a7e035124a07d062c57252eeee7b82d Mon Sep 17 00:00:00 2001 From: biplavbarua Date: Fri, 9 Jan 2026 18:32:02 +0530 Subject: [PATCH 1/9] Refactor: Move event handlers from simple-modals to respective files --- frontend/src/ts/modals/simple-modals-base.ts | 67 ++++++++ frontend/src/ts/modals/simple-modals.ts | 160 +------------------ frontend/src/ts/pages/account-settings.ts | 61 +++++++ frontend/src/ts/pages/settings.ts | 31 ++++ 4 files changed, 164 insertions(+), 155 deletions(-) create mode 100644 frontend/src/ts/modals/simple-modals-base.ts diff --git a/frontend/src/ts/modals/simple-modals-base.ts b/frontend/src/ts/modals/simple-modals-base.ts new file mode 100644 index 000000000000..d6004fa3f685 --- /dev/null +++ b/frontend/src/ts/modals/simple-modals-base.ts @@ -0,0 +1,67 @@ +import * as Notifications from "../elements/notifications"; +import { ShowOptions } from "../utils/animated-modal"; +import { SimpleModal } from "../utils/simple-modal"; + +export type PopupKey = + | "updateEmail" + | "updateName" + | "updatePassword" + | "removeGoogleAuth" + | "removeGithubAuth" + | "removePasswordAuth" + | "addPasswordAuth" + | "deleteAccount" + | "resetAccount" + | "optOutOfLeaderboards" + | "applyCustomFont" + | "resetPersonalBests" + | "resetSettings" + | "revokeAllTokens" + | "unlinkDiscord" + | "editApeKey" + | "deleteCustomText" + | "deleteCustomTextLong" + | "resetProgressCustomTextLong" + | "updateCustomTheme" + | "deleteCustomTheme" + | "devGenerateData" + | "lbGoToPage"; + +export const list: Record = { + updateEmail: undefined, + updateName: undefined, + updatePassword: undefined, + removeGoogleAuth: undefined, + removeGithubAuth: undefined, + removePasswordAuth: undefined, + addPasswordAuth: undefined, + deleteAccount: undefined, + resetAccount: undefined, + optOutOfLeaderboards: undefined, + applyCustomFont: undefined, + resetPersonalBests: undefined, + resetSettings: undefined, + revokeAllTokens: undefined, + unlinkDiscord: undefined, + editApeKey: undefined, + deleteCustomText: undefined, + deleteCustomTextLong: undefined, + resetProgressCustomTextLong: undefined, + updateCustomTheme: undefined, + deleteCustomTheme: undefined, + devGenerateData: undefined, + lbGoToPage: undefined, +}; + +export function showPopup( + key: PopupKey, + showParams = [] as string[], + showOptions: ShowOptions = {}, +): void { + const popup = list[key]; + if (popup === undefined) { + Notifications.add("Failed to show popup - popup is not defined", -1); + return; + } + popup.show(showParams, showOptions); +} diff --git a/frontend/src/ts/modals/simple-modals.ts b/frontend/src/ts/modals/simple-modals.ts index 1bf579504415..da0c4d60f9f3 100644 --- a/frontend/src/ts/modals/simple-modals.ts +++ b/frontend/src/ts/modals/simple-modals.ts @@ -35,7 +35,7 @@ import { SimpleModal, TextInput, } from "../utils/simple-modal"; -import { ShowOptions } from "../utils/animated-modal"; + import { GenerateDataRequest } from "@monkeytype/contracts/dev"; import { PasswordSchema, @@ -47,56 +47,10 @@ import FileStorage from "../utils/file-storage"; import { z } from "zod"; import { remoteValidation } from "../utils/remote-validation"; -type PopupKey = - | "updateEmail" - | "updateName" - | "updatePassword" - | "removeGoogleAuth" - | "removeGithubAuth" - | "removePasswordAuth" - | "addPasswordAuth" - | "deleteAccount" - | "resetAccount" - | "optOutOfLeaderboards" - | "applyCustomFont" - | "resetPersonalBests" - | "resetSettings" - | "revokeAllTokens" - | "unlinkDiscord" - | "editApeKey" - | "deleteCustomText" - | "deleteCustomTextLong" - | "resetProgressCustomTextLong" - | "updateCustomTheme" - | "deleteCustomTheme" - | "devGenerateData" - | "lbGoToPage"; - -const list: Record = { - updateEmail: undefined, - updateName: undefined, - updatePassword: undefined, - removeGoogleAuth: undefined, - removeGithubAuth: undefined, - removePasswordAuth: undefined, - addPasswordAuth: undefined, - deleteAccount: undefined, - resetAccount: undefined, - optOutOfLeaderboards: undefined, - applyCustomFont: undefined, - resetPersonalBests: undefined, - resetSettings: undefined, - revokeAllTokens: undefined, - unlinkDiscord: undefined, - editApeKey: undefined, - deleteCustomText: undefined, - deleteCustomTextLong: undefined, - resetProgressCustomTextLong: undefined, - updateCustomTheme: undefined, - deleteCustomTheme: undefined, - devGenerateData: undefined, - lbGoToPage: undefined, -}; +import { list, PopupKey, showPopup } from "./simple-modals-base"; + +export { list, showPopup }; +export type { PopupKey }; type AuthMethod = "password" | "github.com" | "google.com"; @@ -1321,107 +1275,3 @@ list.lbGoToPage = new SimpleModal({ }; }, }); - -export function showPopup( - key: PopupKey, - showParams = [] as string[], - showOptions: ShowOptions = {}, -): void { - const popup = list[key]; - if (popup === undefined) { - Notifications.add("Failed to show popup - popup is not defined", -1); - return; - } - popup.show(showParams, showOptions); -} - -//todo: move these event handlers to their respective files (either global event files or popup files) -$(".pageAccountSettings").on("click", "#unlinkDiscordButton", () => { - showPopup("unlinkDiscord"); -}); - -$(".pageAccountSettings").on("click", "#removeGoogleAuth", () => { - showPopup("removeGoogleAuth"); -}); - -$(".pageAccountSettings").on("click", "#removeGithubAuth", () => { - showPopup("removeGithubAuth"); -}); - -$(".pageAccountSettings").on("click", "#removePasswordAuth", () => { - showPopup("removePasswordAuth"); -}); - -$("#resetSettingsButton").on("click", () => { - showPopup("resetSettings"); -}); - -$(".pageAccountSettings").on("click", "#revokeAllTokens", () => { - showPopup("revokeAllTokens"); -}); - -$(".pageAccountSettings").on("click", "#resetPersonalBestsButton", () => { - showPopup("resetPersonalBests"); -}); - -$(".pageAccountSettings").on("click", "#updateAccountName", () => { - showPopup("updateName"); -}); - -$("#bannerCenter").on("click", ".banner .text .openNameChange", () => { - showPopup("updateName"); -}); - -$(".pageAccountSettings").on("click", "#addPasswordAuth", () => { - showPopup("addPasswordAuth"); -}); - -$(".pageAccountSettings").on("click", "#emailPasswordAuth", () => { - showPopup("updateEmail"); -}); - -$(".pageAccountSettings").on("click", "#passPasswordAuth", () => { - showPopup("updatePassword"); -}); - -$(".pageAccountSettings").on("click", "#deleteAccount", () => { - showPopup("deleteAccount"); -}); - -$(".pageAccountSettings").on("click", "#resetAccount", () => { - showPopup("resetAccount"); -}); - -$(".pageAccountSettings").on("click", "#optOutOfLeaderboardsButton", () => { - showPopup("optOutOfLeaderboards"); -}); - -$(".pageSettings").on( - "click", - ".section.themes .customTheme .delButton", - (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; - showPopup("deleteCustomTheme", [customThemeId]); - }, -); - -$(".pageSettings").on( - "click", - ".section.themes .customTheme .editButton", - (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; - showPopup("updateCustomTheme", [customThemeId], { - focusFirstInput: "focusAndSelect", - }); - }, -); - -$(".pageSettings").on( - "click", - ".section[data-config-name='fontFamily'] button[data-config-value='custom']", - () => { - showPopup("applyCustomFont"); - }, -); diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 66de98e1a522..1442cd815235 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -13,6 +13,7 @@ import * as Notifications from "../elements/notifications"; import { z } from "zod"; import * as AuthEvent from "../observables/auth-event"; import { qs, qsa, qsr, onWindowLoad } from "../utils/dom"; +import { showPopup } from "../modals/simple-modals-base"; const pageElement = qsr(".page.pageAccountSettings"); @@ -213,3 +214,63 @@ export const page = new PageWithUrlParams({ onWindowLoad(() => { Skeleton.save("pageAccountSettings"); }); + +$(".pageAccountSettings").on("click", "#unlinkDiscordButton", () => { + showPopup("unlinkDiscord"); +}); + +$(".pageAccountSettings").on("click", "#removeGoogleAuth", () => { + showPopup("removeGoogleAuth"); +}); + +$(".pageAccountSettings").on("click", "#removeGithubAuth", () => { + showPopup("removeGithubAuth"); +}); + +$(".pageAccountSettings").on("click", "#removePasswordAuth", () => { + showPopup("removePasswordAuth"); +}); + +$("#resetSettingsButton").on("click", () => { + showPopup("resetSettings"); +}); + +$(".pageAccountSettings").on("click", "#revokeAllTokens", () => { + showPopup("revokeAllTokens"); +}); + +$(".pageAccountSettings").on("click", "#resetPersonalBestsButton", () => { + showPopup("resetPersonalBests"); +}); + +$(".pageAccountSettings").on("click", "#updateAccountName", () => { + showPopup("updateName"); +}); + +$("#bannerCenter").on("click", ".banner .text .openNameChange", () => { + showPopup("updateName"); +}); + +$(".pageAccountSettings").on("click", "#addPasswordAuth", () => { + showPopup("addPasswordAuth"); +}); + +$(".pageAccountSettings").on("click", "#emailPasswordAuth", () => { + showPopup("updateEmail"); +}); + +$(".pageAccountSettings").on("click", "#passPasswordAuth", () => { + showPopup("updatePassword"); +}); + +$(".pageAccountSettings").on("click", "#deleteAccount", () => { + showPopup("deleteAccount"); +}); + +$(".pageAccountSettings").on("click", "#resetAccount", () => { + showPopup("resetAccount"); +}); + +$(".pageAccountSettings").on("click", "#optOutOfLeaderboardsButton", () => { + showPopup("optOutOfLeaderboards"); +}); diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index e539d8b84df3..1370a06864c5 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -44,6 +44,7 @@ import * as CustomFontPicker from "../elements/settings/custom-font-picker"; import * as AuthEvent from "../observables/auth-event"; import * as FpsLimitSection from "../elements/settings/fps-limit-section"; import { qs, qsa, qsr, onWindowLoad } from "../utils/dom"; +import { showPopup } from "../modals/simple-modals-base"; let settingsInitialized = false; @@ -1033,3 +1034,33 @@ export const page = new PageWithUrlParams({ onWindowLoad(async () => { Skeleton.save("pageSettings"); }); + +$(".pageSettings").on( + "click", + ".section.themes .customTheme .delButton", + (e) => { + const $parentElement = $(e.currentTarget).parent(".customTheme.button"); + const customThemeId = $parentElement.attr("customThemeId") as string; + showPopup("deleteCustomTheme", [customThemeId]); + }, +); + +$(".pageSettings").on( + "click", + ".section.themes .customTheme .editButton", + (e) => { + const $parentElement = $(e.currentTarget).parent(".customTheme.button"); + const customThemeId = $parentElement.attr("customThemeId") as string; + showPopup("updateCustomTheme", [customThemeId], { + focusFirstInput: "focusAndSelect", + }); + }, +); + +$(".pageSettings").on( + "click", + ".section[data-config-name='fontFamily'] button[data-config-value='custom']", + () => { + showPopup("applyCustomFont"); + }, +); From d90b198a8f86da63d62706398c31ec60f848cc83 Mon Sep 17 00:00:00 2001 From: biplavbarua Date: Thu, 15 Jan 2026 13:45:05 +0530 Subject: [PATCH 2/9] refactor: move event handlers per Copilot feedback --- frontend/src/ts/modals/simple-modals.ts | 4 ++++ frontend/src/ts/pages/account-settings.ts | 18 ------------------ frontend/src/ts/pages/settings.ts | 4 ++++ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/frontend/src/ts/modals/simple-modals.ts b/frontend/src/ts/modals/simple-modals.ts index da0c4d60f9f3..cae7c458d98a 100644 --- a/frontend/src/ts/modals/simple-modals.ts +++ b/frontend/src/ts/modals/simple-modals.ts @@ -1275,3 +1275,7 @@ list.lbGoToPage = new SimpleModal({ }; }, }); + +$("#bannerCenter").on("click", ".banner .text .openNameChange", () => { + showPopup("updateName"); +}); diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 1b22b549c3d3..20ad81277f2b 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -231,25 +231,7 @@ $(".pageAccountSettings").on("click", "#removePasswordAuth", () => { showPopup("removePasswordAuth"); }); -$("#resetSettingsButton").on("click", () => { - showPopup("resetSettings"); -}); - -$(".pageAccountSettings").on("click", "#revokeAllTokens", () => { - showPopup("revokeAllTokens"); -}); - -$(".pageAccountSettings").on("click", "#resetPersonalBestsButton", () => { - showPopup("resetPersonalBests"); -}); - -$(".pageAccountSettings").on("click", "#updateAccountName", () => { - showPopup("updateName"); -}); -$("#bannerCenter").on("click", ".banner .text .openNameChange", () => { - showPopup("updateName"); -}); $(".pageAccountSettings").on("click", "#addPasswordAuth", () => { showPopup("addPasswordAuth"); diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 1e24ab9b8100..8e115a61f943 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -1064,3 +1064,7 @@ $(".pageSettings").on( showPopup("applyCustomFont"); }, ); + +$("#resetSettingsButton").on("click", () => { + showPopup("resetSettings"); +}); From c7a084ed07af9e775c9def76a27d4d7c4a151f99 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 09:44:39 +0100 Subject: [PATCH 3/9] format --- frontend/src/ts/pages/account-settings.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 20ad81277f2b..2f94936636b4 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -231,8 +231,6 @@ $(".pageAccountSettings").on("click", "#removePasswordAuth", () => { showPopup("removePasswordAuth"); }); - - $(".pageAccountSettings").on("click", "#addPasswordAuth", () => { showPopup("addPasswordAuth"); }); From d9ccf62c99f6c4447f74fcd162cdebaee73cd9a8 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 09:45:33 +0100 Subject: [PATCH 4/9] reorder --- frontend/src/ts/pages/account-settings.ts | 58 +++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 2f94936636b4..0d78c51dca59 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -186,35 +186,6 @@ qs(".page.pageAccountSettings #setStreakHourOffset")?.on("click", () => { StreakHourOffsetModal.show(); }); -AuthEvent.subscribe((event) => { - if (event.type === "authConfigUpdated") { - updateUI(); - } -}); - -export const page = new PageWithUrlParams({ - id: "accountSettings", - display: "Account Settings", - element: pageElement, - path: "/account-settings", - urlParamsSchema: UrlParameterSchema, - afterHide: async (): Promise => { - Skeleton.remove("pageAccountSettings"); - }, - beforeShow: async (options): Promise => { - if (options.urlParams?.tab !== undefined) { - state.tab = options.urlParams.tab; - } - Skeleton.append("pageAccountSettings", "main"); - pageElement.qs(`.tab[data-tab="${state.tab}"]`)?.addClass("active"); - updateUI(); - }, -}); - -onDOMReady(() => { - Skeleton.save("pageAccountSettings"); -}); - $(".pageAccountSettings").on("click", "#unlinkDiscordButton", () => { showPopup("unlinkDiscord"); }); @@ -254,3 +225,32 @@ $(".pageAccountSettings").on("click", "#resetAccount", () => { $(".pageAccountSettings").on("click", "#optOutOfLeaderboardsButton", () => { showPopup("optOutOfLeaderboards"); }); + +AuthEvent.subscribe((event) => { + if (event.type === "authConfigUpdated") { + updateUI(); + } +}); + +export const page = new PageWithUrlParams({ + id: "accountSettings", + display: "Account Settings", + element: pageElement, + path: "/account-settings", + urlParamsSchema: UrlParameterSchema, + afterHide: async (): Promise => { + Skeleton.remove("pageAccountSettings"); + }, + beforeShow: async (options): Promise => { + if (options.urlParams?.tab !== undefined) { + state.tab = options.urlParams.tab; + } + Skeleton.append("pageAccountSettings", "main"); + pageElement.qs(`.tab[data-tab="${state.tab}"]`)?.addClass("active"); + updateUI(); + }, +}); + +onDOMReady(() => { + Skeleton.save("pageAccountSettings"); +}); From fedb274c5f0eefa911e7a2e1a5d93f8422bef8a9 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 09:46:45 +0100 Subject: [PATCH 5/9] use qs --- frontend/src/ts/pages/account-settings.ts | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 0d78c51dca59..5229a5fe1dbe 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -186,45 +186,49 @@ qs(".page.pageAccountSettings #setStreakHourOffset")?.on("click", () => { StreakHourOffsetModal.show(); }); -$(".pageAccountSettings").on("click", "#unlinkDiscordButton", () => { +qs(".pageAccountSettings")?.onChild("click", "#unlinkDiscordButton", () => { showPopup("unlinkDiscord"); }); -$(".pageAccountSettings").on("click", "#removeGoogleAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#removeGoogleAuth", () => { showPopup("removeGoogleAuth"); }); -$(".pageAccountSettings").on("click", "#removeGithubAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#removeGithubAuth", () => { showPopup("removeGithubAuth"); }); -$(".pageAccountSettings").on("click", "#removePasswordAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#removePasswordAuth", () => { showPopup("removePasswordAuth"); }); -$(".pageAccountSettings").on("click", "#addPasswordAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#addPasswordAuth", () => { showPopup("addPasswordAuth"); }); -$(".pageAccountSettings").on("click", "#emailPasswordAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#emailPasswordAuth", () => { showPopup("updateEmail"); }); -$(".pageAccountSettings").on("click", "#passPasswordAuth", () => { +qs(".pageAccountSettings")?.onChild("click", "#passPasswordAuth", () => { showPopup("updatePassword"); }); -$(".pageAccountSettings").on("click", "#deleteAccount", () => { +qs(".pageAccountSettings")?.onChild("click", "#deleteAccount", () => { showPopup("deleteAccount"); }); -$(".pageAccountSettings").on("click", "#resetAccount", () => { +qs(".pageAccountSettings")?.onChild("click", "#resetAccount", () => { showPopup("resetAccount"); }); -$(".pageAccountSettings").on("click", "#optOutOfLeaderboardsButton", () => { - showPopup("optOutOfLeaderboards"); -}); +qs(".pageAccountSettings")?.onChild( + "click", + "#optOutOfLeaderboardsButton", + () => { + showPopup("optOutOfLeaderboards"); + }, +); AuthEvent.subscribe((event) => { if (event.type === "authConfigUpdated") { From bfed27216a0b3926830d8aef86df0c550264b7c3 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 09:48:10 +0100 Subject: [PATCH 6/9] reorder --- frontend/src/ts/pages/settings.ts | 68 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 8e115a61f943..1511a0655098 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -980,6 +980,40 @@ qsa(".pageSettings .section .groupTitle button")?.on("click", (e) => { }); }); +$(".pageSettings").on( + "click", + ".section.themes .customTheme .delButton", + (e) => { + const $parentElement = $(e.currentTarget).parent(".customTheme.button"); + const customThemeId = $parentElement.attr("customThemeId") as string; + showPopup("deleteCustomTheme", [customThemeId]); + }, +); + +$(".pageSettings").on( + "click", + ".section.themes .customTheme .editButton", + (e) => { + const $parentElement = $(e.currentTarget).parent(".customTheme.button"); + const customThemeId = $parentElement.attr("customThemeId") as string; + showPopup("updateCustomTheme", [customThemeId], { + focusFirstInput: "focusAndSelect", + }); + }, +); + +$(".pageSettings").on( + "click", + ".section[data-config-name='fontFamily'] button[data-config-value='custom']", + () => { + showPopup("applyCustomFont"); + }, +); + +$("#resetSettingsButton").on("click", () => { + showPopup("resetSettings"); +}); + ConfigEvent.subscribe(({ key, newValue }) => { if (key === "fullConfigChange") setEventDisabled(true); if (key === "fullConfigChangeFinished") setEventDisabled(false); @@ -1034,37 +1068,3 @@ export const page = new PageWithUrlParams({ onDOMReady(async () => { Skeleton.save("pageSettings"); }); - -$(".pageSettings").on( - "click", - ".section.themes .customTheme .delButton", - (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; - showPopup("deleteCustomTheme", [customThemeId]); - }, -); - -$(".pageSettings").on( - "click", - ".section.themes .customTheme .editButton", - (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; - showPopup("updateCustomTheme", [customThemeId], { - focusFirstInput: "focusAndSelect", - }); - }, -); - -$(".pageSettings").on( - "click", - ".section[data-config-name='fontFamily'] button[data-config-value='custom']", - () => { - showPopup("applyCustomFont"); - }, -); - -$("#resetSettingsButton").on("click", () => { - showPopup("resetSettings"); -}); From d8f881be5fe31a7c7d5ce1cb9ad6b659e109158b Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 09:54:44 +0100 Subject: [PATCH 7/9] use qs --- frontend/src/ts/pages/settings.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 1511a0655098..14883b601beb 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -980,29 +980,33 @@ qsa(".pageSettings .section .groupTitle button")?.on("click", (e) => { }); }); -$(".pageSettings").on( +qs(".pageSettings")?.onChild( "click", ".section.themes .customTheme .delButton", (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; + const parentElement = (e.childTarget as HTMLElement).closest( + ".customTheme.button", + ) as HTMLElement; + const customThemeId = parentElement.getAttribute("customThemeId") as string; showPopup("deleteCustomTheme", [customThemeId]); }, ); -$(".pageSettings").on( +qs(".pageSettings")?.onChild( "click", ".section.themes .customTheme .editButton", (e) => { - const $parentElement = $(e.currentTarget).parent(".customTheme.button"); - const customThemeId = $parentElement.attr("customThemeId") as string; + const parentElement = (e.childTarget as HTMLElement).closest( + ".customTheme.button", + ) as HTMLElement; + const customThemeId = parentElement.getAttribute("customThemeId") as string; showPopup("updateCustomTheme", [customThemeId], { focusFirstInput: "focusAndSelect", }); }, ); -$(".pageSettings").on( +qs(".pageSettings")?.onChild( "click", ".section[data-config-name='fontFamily'] button[data-config-value='custom']", () => { @@ -1010,7 +1014,7 @@ $(".pageSettings").on( }, ); -$("#resetSettingsButton").on("click", () => { +qs(".pageSettings #resetSettingsButton")?.on("click", () => { showPopup("resetSettings"); }); From e6e88a23f2ee3274480b0b9349d640876119f19e Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 16:05:35 +0100 Subject: [PATCH 8/9] missing events --- frontend/src/ts/pages/account-settings.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/ts/pages/account-settings.ts b/frontend/src/ts/pages/account-settings.ts index 5229a5fe1dbe..69b4a3e7ec2a 100644 --- a/frontend/src/ts/pages/account-settings.ts +++ b/frontend/src/ts/pages/account-settings.ts @@ -230,6 +230,22 @@ qs(".pageAccountSettings")?.onChild( }, ); +qs(".pageAccountSettings")?.onChild("click", "#revokeAllTokens", () => { + showPopup("revokeAllTokens"); +}); + +qs(".pageAccountSettings")?.onChild( + "click", + "#resetPersonalBestsButton", + () => { + showPopup("resetPersonalBests"); + }, +); + +qs(".pageAccountSettings")?.onChild("click", "#updateAccountName", () => { + showPopup("updateName"); +}); + AuthEvent.subscribe((event) => { if (event.type === "authConfigUpdated") { updateUI(); From 9748bc05e7e4d973651188a85674cf4e67a3ebd4 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 15 Jan 2026 16:12:46 +0100 Subject: [PATCH 9/9] review --- frontend/src/ts/pages/settings.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/ts/pages/settings.ts b/frontend/src/ts/pages/settings.ts index 14883b601beb..9fab875178a8 100644 --- a/frontend/src/ts/pages/settings.ts +++ b/frontend/src/ts/pages/settings.ts @@ -984,10 +984,12 @@ qs(".pageSettings")?.onChild( "click", ".section.themes .customTheme .delButton", (e) => { - const parentElement = (e.childTarget as HTMLElement).closest( + const parentElement = (e.childTarget as HTMLElement | null)?.closest( ".customTheme.button", - ) as HTMLElement; - const customThemeId = parentElement.getAttribute("customThemeId") as string; + ); + const customThemeId = parentElement?.getAttribute( + "customThemeId", + ) as string; showPopup("deleteCustomTheme", [customThemeId]); }, ); @@ -996,10 +998,12 @@ qs(".pageSettings")?.onChild( "click", ".section.themes .customTheme .editButton", (e) => { - const parentElement = (e.childTarget as HTMLElement).closest( + const parentElement = (e.childTarget as HTMLElement | null)?.closest( ".customTheme.button", - ) as HTMLElement; - const customThemeId = parentElement.getAttribute("customThemeId") as string; + ); + const customThemeId = parentElement?.getAttribute( + "customThemeId", + ) as string; showPopup("updateCustomTheme", [customThemeId], { focusFirstInput: "focusAndSelect", });