From b7965bf71d44253dd198c4a2bc66f50e733d260c Mon Sep 17 00:00:00 2001 From: Jack Case Date: Fri, 14 Nov 2025 01:24:39 +0000 Subject: [PATCH] fixed some state-bugs --- pages/action_popup.html | 2 +- src/browser-action.ts | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pages/action_popup.html b/pages/action_popup.html index 4a609d7..7e06e93 100644 --- a/pages/action_popup.html +++ b/pages/action_popup.html @@ -8,7 +8,7 @@ Slop Farmer -
diff --git a/src/browser-action.ts b/src/browser-action.ts index 8155b3d..4205316 100644 --- a/src/browser-action.ts +++ b/src/browser-action.ts @@ -10,6 +10,7 @@ class PopupState { this.logged_in = logged_in this.page_sections = page_sections this.visible_section = visible_section + this.setVisibleSection(visible_section) } setVisibleSection(section_id: string) { @@ -20,14 +21,6 @@ class PopupState { } } -if (localStorage.getItem("accessToken")) { - login_status.setAttribute("style", "visibility: visible;") -} - -login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() }) - -signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() }) - async function submit_login_form() { const login_url = new URL("/login", API_URL) @@ -84,5 +77,13 @@ function initialize_popup() { page_sections.set("login", login_section) page_sections.set("report", report_section) - const popup_state = new PopupState(false, page_sections, "signup_section") -} \ No newline at end of file + const popup_state = new PopupState(false, page_sections, "signup") + + login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() }) + + signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() }) +} + +addEventListener("DOMContentLoaded", (event) => { + initialize_popup() +}) \ No newline at end of file