fix: theme toggle not saving correctly

This commit is contained in:
Herculino Trotta
2025-11-12 00:10:42 -03:00
parent d3f8a637bc
commit 2bc5e24e51
2 changed files with 4 additions and 3 deletions

View File

@@ -145,7 +145,7 @@ def toggle_theme(request):
elif request.session["theme"] == "wygiwyh_light":
request.session["theme"] = "wygiwyh_dark"
else:
request.session["theme"] = "wygiwyh_dark"
request.session["theme"] = "wygiwyh_light"
return HttpResponse(
status=204,

View File

@@ -1,14 +1,15 @@
{% load settings %}
{% load i18n %}
<label class="swap swap-rotate btn btn-secondary btn-sm" data-tippy-content="{% translate 'Toggle theme' %}">
<label class="swap swap-rotate btn btn-secondary btn-sm"
data-tippy-content="{% translate 'Toggle theme' %}">
<input type="checkbox"
hx-get="{% url 'toggle_theme' %}"
_="on load
if <html/>'s @data-theme is 'wygiwyh_dark' set my.checked to true end
end
on change
if my.checked set <html/>'s @data-theme to 'wygiwyh_dark'
else set <html/>'s @data-theme to 'wygiwyh_light'
then fetch {% url 'toggle_theme' %}
end
end"
/>