1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 18:51:40 +02:00

Refresh avatar display after uploading

This commit is contained in:
Toby Zerner
2015-03-27 11:49:26 +10:30
parent 38bbfc78d0
commit 257a3fde1a
5 changed files with 36 additions and 9 deletions

View File

@@ -9,12 +9,15 @@ export default Ember.Component.extend({
classNames: ['avatar-editor', 'dropdown'],
classNameBindings: ['loading'],
click: function(e) {
if (! this.get('user.avatarUrl')) {
e.preventDefault();
e.stopPropagation();
this.send('upload');
}
didInsertElement: function() {
var component = this;
this.$('.dropdown-toggle').click(function(e) {
if (! component.get('user.avatarUrl')) {
e.preventDefault();
e.stopPropagation();
component.send('upload');
}
});
},
actions: {
@@ -37,9 +40,18 @@ export default Ember.Component.extend({
processData: false,
complete: function() {
component.set('loading', false);
},
success: function(data) {
Ember.run.next(function() {
component.get('store').pushPayload(data);
});
}
});
});
},
remove: function() {
this.get('store').push('user', {id: this.get('user.id'), avatarUrl: null});
}
}
});