mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Extract save_cookies_from_locale comment-method
This commit is contained in:
@@ -9,11 +9,7 @@ class UserLocaleSetter
|
||||
|
||||
def call
|
||||
save_locale_from_params
|
||||
|
||||
# After logging in, check if the user chose a locale before
|
||||
if current_user_locale.nil? && cookies[:locale] && available_locale?(params_locale)
|
||||
current_user&.update!(locale: params_locale)
|
||||
end
|
||||
save_locale_from_cookies
|
||||
|
||||
I18n.locale = valid_current_locale
|
||||
end
|
||||
@@ -47,6 +43,13 @@ class UserLocaleSetter
|
||||
cookies[:locale] = params_locale
|
||||
end
|
||||
|
||||
def save_locale_from_cookies
|
||||
return unless current_user_locale.nil? && cookies[:locale] &&
|
||||
available_locale?(params_locale)
|
||||
|
||||
current_user&.update!(locale: params_locale)
|
||||
end
|
||||
|
||||
def available_locale?(locale)
|
||||
self.class.available_locale?(locale)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user