Browse Source

propagate avatar change to store

Rafał Pitoń 10 years ago
parent
commit
52043d8c03
1 changed files with 14 additions and 0 deletions
  1. 14 0
      misago/emberapp/app/services/auth.js

+ 14 - 0
misago/emberapp/app/services/auth.js

@@ -74,6 +74,20 @@ export default Ember.Service.extend({
     this.setUrlNameOnUser();
     this.setUrlNameOnUser();
   }.observes('user.id', 'user.slug'),
   }.observes('user.id', 'user.slug'),
 
 
+  // Propagate changes to store for nice real-time changes
+
+  propagateAvatarChange: function() {
+    var user = this.store.getById('user', this.get('user.id'));
+    if (user) {
+      user.set('avatar_hash', this.get('user.avatar_hash'));
+    }
+
+    var profile = this.store.getById('user-profile', this.get('user.id'));
+    if (profile) {
+      profile.set('avatar_hash', this.get('user.avatar_hash'));
+    }
+  }.observes('user.avatar_hash'),
+
   // Return user as POJO
   // Return user as POJO
 
 
   getUserPOJO: function() {
   getUserPOJO: function() {