From 88aff9cbe96de1218ebef1e86585fbc7ae77e779 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sun, 28 Apr 2024 11:44:25 -0400 Subject: [PATCH] fix darkmode toggle --- routes.go | 10 +++++----- templates/settings.html | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/routes.go b/routes.go index b68144d..644c0ce 100644 --- a/routes.go +++ b/routes.go @@ -772,14 +772,14 @@ func Settings(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { setCookie(w, "", name, r.FormValue(name)) } state.Dark = new(bool) - if r.FormValue("undarkmode") == "" { + dark := r.FormValue("darkmode") + undark := r.FormValue("undarkmode") + if dark == "0" && undark != "0" { + } else if dark == "0" && undark == "0" { setCookie(w, "", "Dark", "0") - } else if r.FormValue("darkmode") != "" { + } else { setCookie(w, "", "Dark", "1") *state.Dark = true - } else { - setCookie(w, "", "Dark", "0") - *state.Dark = false } if r.FormValue("shownsfw") != "" { setCookie(w, "", "ShowNSFW", "1") diff --git a/templates/settings.html b/templates/settings.html index f4de045..97ddb40 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -111,12 +111,16 @@ dark mode +
+ {{ if not .Dark }} + {{ end }} +