mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: setting custom avatar would not work a lot of the time
Due to internal structure we were often caching "redirect" images.
This commit is contained in:
parent
be16bbdd89
commit
05a56b25a9
3 changed files with 17 additions and 10 deletions
|
@ -14,9 +14,6 @@ export default Em.Component.extend(UploadMixin, {
|
||||||
uploadDone: function(data) {
|
uploadDone: function(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
// indicates the users is using an uploaded avatar
|
|
||||||
this.set("custom_avatar_upload_id", data.result.upload_id);
|
|
||||||
|
|
||||||
// display a warning whenever the image is not a square
|
// display a warning whenever the image is not a square
|
||||||
this.set("imageIsNotASquare", data.result.width !== data.result.height);
|
this.set("imageIsNotASquare", data.result.width !== data.result.height);
|
||||||
|
|
||||||
|
@ -26,6 +23,11 @@ export default Em.Component.extend(UploadMixin, {
|
||||||
// this will also capture the first frame of animated avatars when they're not allowed
|
// this will also capture the first frame of animated avatars when they're not allowed
|
||||||
Discourse.Utilities.cropAvatar(data.result.url, data.files[0].type).then(function(avatarTemplate) {
|
Discourse.Utilities.cropAvatar(data.result.url, data.files[0].type).then(function(avatarTemplate) {
|
||||||
self.set("uploadedAvatarTemplate", avatarTemplate);
|
self.set("uploadedAvatarTemplate", avatarTemplate);
|
||||||
|
|
||||||
|
// indicates the users is using an uploaded avatar (must happen after cropping, otherwise
|
||||||
|
// we will attempt to load an invalid avatar and cache a redirect to old one, uploadedAvatarTemplate
|
||||||
|
// trumps over custom avatar upload id)
|
||||||
|
self.set("custom_avatar_upload_id", data.result.upload_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
// the upload is now done
|
// the upload is now done
|
||||||
|
|
|
@ -351,10 +351,13 @@ Discourse.User = Discourse.Model.extend({
|
||||||
Change avatar selection
|
Change avatar selection
|
||||||
*/
|
*/
|
||||||
pickAvatar: function(uploadId) {
|
pickAvatar: function(uploadId) {
|
||||||
this.set("uploaded_avatar_id", uploadId);
|
var self = this;
|
||||||
|
|
||||||
return Discourse.ajax("/users/" + this.get("username_lower") + "/preferences/avatar/pick", {
|
return Discourse.ajax("/users/" + this.get("username_lower") + "/preferences/avatar/pick", {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: { upload_id: uploadId }
|
data: { upload_id: uploadId }
|
||||||
|
}).then(function(){
|
||||||
|
self.set('uploaded_avatar_id', uploadId);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,17 @@ export default RestrictedUserRoute.extend(ShowFooter, {
|
||||||
|
|
||||||
// sends the information to the server if it has changed
|
// sends the information to the server if it has changed
|
||||||
if (avatarSelector.get('selectedUploadId') !== user.get('uploaded_avatar_id')) {
|
if (avatarSelector.get('selectedUploadId') !== user.get('uploaded_avatar_id')) {
|
||||||
user.pickAvatar(avatarSelector.get('selectedUploadId'));
|
user.pickAvatar(avatarSelector.get('selectedUploadId'))
|
||||||
}
|
.then(function(){
|
||||||
|
|
||||||
// saves the data back
|
|
||||||
user.setProperties(avatarSelector.getProperties(
|
user.setProperties(avatarSelector.getProperties(
|
||||||
'system_avatar_upload_id',
|
'system_avatar_upload_id',
|
||||||
'gravatar_avatar_upload_id',
|
'gravatar_avatar_upload_id',
|
||||||
'custom_avatar_upload_id'
|
'custom_avatar_upload_id'
|
||||||
));
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// saves the data back
|
||||||
avatarSelector.send('closeModal');
|
avatarSelector.send('closeModal');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue