소스 검색

Save groups on RosterItem. updates #83

JC Brand 11 년 전
부모
커밋
01c2c5d93c
1개의 변경된 파일16개의 추가작업 그리고 9개의 파일을 삭제
  1. 16 9
      converse.js

+ 16 - 9
converse.js

@@ -564,7 +564,7 @@
                 this.connection.xmlInput = function (body) { console.log(body); };
                 this.connection.xmlOutput = function (body) { console.log(body); };
                 Strophe.log = function (level, msg) { console.log(level+' '+msg); };
-                Strophe.error = function (msg) { 
+                Strophe.error = function (msg) {
                     console.log('ERROR: '+msg);
                 };
             }
@@ -3060,21 +3060,28 @@
                             return;
                         }
                         this.create({
-                            jid: item.jid,
-                            subscription: item.subscription,
                             ask: item.ask,
                             fullname: item.name || item.jid,
-                            is_last: is_last
+                            groups: item.groups,
+                            is_last: is_last,
+                            jid: item.jid,
+                            subscription: item.subscription
                         });
                     } else {
                         if ((item.subscription === 'none') && (item.ask === null)) {
                             // This user is no longer in our roster
                             model.destroy();
-                        } else if (model.get('subscription') !== item.subscription || model.get('ask') !== item.ask) {
-                            // only modify model attributes if they are different from the
-                            // ones that were already set when the rosterItem was added
-                            model.set({'subscription': item.subscription, 'ask': item.ask, 'requesting': null});
-                            model.save();
+                        } else {
+                            // We only find out about requesting contacts via the
+                            // presence handler, so if we receive a contact
+                            // here, we know they aren't requesting anymore.
+                            // see docs/DEVELOPER.rst
+                            model.save({
+                                subscription: item.subscription,
+                                ask: item.ask,
+                                requesting: null,
+                                groups: item.groups
+                            });
                         }
                     }
                 }, this);