diff --git a/app/controllers/settings/profile_picture_controller.rb b/app/controllers/settings/profile_picture_controller.rb index c44e1200..cf869344 100644 --- a/app/controllers/settings/profile_picture_controller.rb +++ b/app/controllers/settings/profile_picture_controller.rb @@ -7,14 +7,26 @@ class Settings::ProfilePictureController < ApplicationController user_attributes = params.require(:user).permit(:show_foreign_themes, :profile_picture_x, :profile_picture_y, :profile_picture_w, :profile_picture_h, :profile_header_x, :profile_header_y, :profile_header_w, :profile_header_h, :profile_picture, :profile_header) if current_user.update(user_attributes) - text = t(".success") - text += t(".notice.profile_picture") if user_attributes[:profile_picture] - text += t(".notice.profile_header") if user_attributes[:profile_header] - flash[:success] = text + flash[:success] = success_flash_message(user_attributes) else flash[:error] = t(".error") end redirect_to settings_profile_path end + + private + + def success_flash_message(user_attributes) + if user_attributes[:profile_picture] && user_attributes[:profile_header] + t(".update.success.both") + elsif user_attributes[:profile_picture] + t(".update.success.profile_picture") + elsif user_attributes[:profile_header] + t(".update.success.profile_header") + else + state = user_attributes[:show_foreign_themes] ? "enabled" : "disabled" + t(".update.success.foreign_themes.#{state}") + end + end end diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index db50ece5..a5023a3e 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -177,11 +177,14 @@ en: error: "Unable to update profile." profile_picture: update: - success: :settings.profile.update.success + success: + profile_picture: "Profile picture updated successfully. It might take a few minutes until your new profile picture is shown everywhere." + profile_header: "Profile header updated successfully. It might take a few minutes until your new profile header is shown everywhere." + both: "Profile picture and header updated successfully. It might take a few minutes until they are shown everywhere." + foreign_themes: + enabled: "You will now see other user's themes when viewing their profiles." + disabled: "You will no longer see other user's themes." error: :settings.profile.update.error - notice: - profile_picture: " It might take a few minutes until your new profile picture is shown everywhere." - profile_header: " It might take a few minutes until your new profile header is shown everywhere." theme: update: success: "Theme saved successfully."