From 9abe164c1b080863e0bd09f484ac0e423523110d Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Wed, 13 Sep 2023 02:06:37 +0000 Subject: [PATCH] Extract method --- app/controllers/application_controller.rb | 5 +++++ app/controllers/themes_controller.rb | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 89a3c5ebe..b87658c3c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -61,6 +61,11 @@ def show_tailwind_theme? cookies.signed[:planningalerts_theme] == "tailwind" end + sig { params(tailwind: T::Boolean).void } + def update_tailwind_theme(tailwind) + cookies.signed[:planningalerts_theme] = ("tailwind" if tailwind) + end + sig { void } def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password) } diff --git a/app/controllers/themes_controller.rb b/app/controllers/themes_controller.rb index bb03b7756..55f1212d6 100644 --- a/app/controllers/themes_controller.rb +++ b/app/controllers/themes_controller.rb @@ -6,11 +6,7 @@ class ThemesController < ApplicationController sig { void } def toggle - cookies.signed[:planningalerts_theme] = if show_tailwind_theme? - nil - else - "tailwind" - end + update_tailwind_theme(!show_tailwind_theme?) redirect_back(fallback_location: root_path) end end