fix darkmode toggle

This commit is contained in:
Ryan Stafford 2024-04-28 11:44:25 -04:00
parent 3cb8b19a4e
commit 88aff9cbe9
2 changed files with 9 additions and 5 deletions

View file

@ -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")

View file

@ -111,12 +111,16 @@
dark mode
</label>
<input type="checkbox" name="darkmode" {{ if is .Dark }}checked{{end}}>
<input type="hidden" name="darkmode" value="0">
</div>
<div id="undarkmode">
<label>
dark mode
</label>
{{ if not .Dark }}
<input type="checkbox" name="undarkmode" checked>
{{ end }}
<input type="hidden" name="undarkmode" value="0">
</div>
<div class="scripting">
<label>