UX: The Site's logo is the selected option when changing the system's user avatar. (#12861)

If the "use_site_small_logo_as_system_avatar" setting is enabled, the site's small logo is displayed as the selected option by the avatar-selector. Choosing a different avatar disables the setting.
This commit is contained in:
Roman Rizzi
2021-04-27 17:28:15 -03:00
committed by GitHub
parent d3c0b6bfe1
commit cdbdb04909
8 changed files with 74 additions and 10 deletions

View File

@@ -1129,11 +1129,9 @@ class UsersController < ApplicationController
if type.blank? || type == 'system'
upload_id = nil
elsif !SiteSetting.allow_uploaded_avatars
return render json: failed_json, status: 422
else
if !SiteSetting.allow_uploaded_avatars
return render json: failed_json, status: 422
end
upload_id = params[:upload_id]
upload = Upload.find_by(id: upload_id)
@@ -1153,6 +1151,10 @@ class UsersController < ApplicationController
end
end
if user.is_system_user?
SiteSetting.use_site_small_logo_as_system_avatar = false
end
user.uploaded_avatar_id = upload_id
user.save!
user.user_avatar.save!
@@ -1187,6 +1189,11 @@ class UsersController < ApplicationController
end
user.uploaded_avatar_id = upload.id
if user.is_system_user?
SiteSetting.use_site_small_logo_as_system_avatar = false
end
user.save!
avatar = user.user_avatar || user.create_user_avatar