From 7013c2944344bd00392153e9488f36336d35ab49 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Thu, 19 Mar 2026 19:37:53 +0000 Subject: [PATCH] refactor(web): clean up review findings from Preact port - Remove duplicate style attribute on happy image preload in templ - Remove unused getAvailableLanguages function from main.tsx - Add type annotation to currentLang variable - Add null check for missing challenge data with localized error Assisted-by: Claude Opus 4.6 via Claude Code Signed-off-by: Xe Iaso --- lib/challenge/proofofwork/proofofwork.templ | 2 +- .../proofofwork/proofofwork_templ.go | 4 +- web/js/main.tsx | 38 ++++++------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/lib/challenge/proofofwork/proofofwork.templ b/lib/challenge/proofofwork/proofofwork.templ index 94b841ff..7a270830 100644 --- a/lib/challenge/proofofwork/proofofwork.templ +++ b/lib/challenge/proofofwork/proofofwork.templ @@ -7,7 +7,7 @@ import ( templ page(localizer *localization.SimpleLocalizer) {
- { localizer.T("loading") }

diff --git a/lib/challenge/proofofwork/proofofwork_templ.go b/lib/challenge/proofofwork/proofofwork_templ.go index 48d2df2d..93999d88 100644 --- a/lib/challenge/proofofwork/proofofwork_templ.go +++ b/lib/challenge/proofofwork/proofofwork_templ.go @@ -34,14 +34,14 @@ func page(localizer *localization.SimpleLocalizer) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
document.documentElement.lang; @@ -91,7 +66,7 @@ const getRedirectUrl = () => { }; let translations: Record = {}; -let currentLang; +let currentLang: string; // Initialize translations const initTranslations = async () => { @@ -179,7 +154,16 @@ function App({ anubisVersion, basePrefix }: AppProps) { } } - const { challenge, rules } = j("anubis_challenge"); + const challengeData = j("anubis_challenge"); + if (!challengeData) { + showError( + t("challenge_error"), + t("challenge_data_missing"), + imageURL("reject", anubisVersion, basePrefix), + ); + return; + } + const { challenge, rules } = challengeData; const process = algorithms[rules.algorithm]; if (!process) {