summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-05-18 08:31:13 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-05-18 08:31:13 +0200
commitc3071d54eb1275e36067f8549a7a7ac2c6876de9 (patch)
tree4669ca1548f7887305cb3ea35aad6b677531000c /lib/Travelynx.pm
parent3668c69d1fad5855fd9bcd190855a7f6c6ec2195 (diff)
parent2107c0bbaf9f4b7f66c09eb7d242790145456292 (diff)
Merge branch 'marudor-darkMode'
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index c4a2b53..2c15154 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -93,6 +93,23 @@ sub startup {
$self->defaults( layout => 'default' );
+ $self->hook(
+ before_dispatch => sub {
+ my ($self) = @_;
+
+ # The "theme" cookie is set client-side if the theme we delivered was
+ # changed by dark mode detection or by using the theme switcher). It's
+ # not part of Mojolicious' session data (and can't be, due to
+ # signing and HTTPOnly), so we need to add it here.
+ for my $cookie ( @{ $self->req->cookies } ) {
+ if ( $cookie->name eq 'theme' ) {
+ $self->session( theme => $cookie->value );
+ return;
+ }
+ }
+ }
+ );
+
$self->attr(
cache_iris_main => sub {
my ($self) = @_;