Skip to content

Commit

Permalink
Extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Sep 13, 2023
1 parent 4d7d255 commit 9abe164
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/themes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9abe164

Please sign in to comment.