Browse Source

Fetch own vcard on startup

JC Brand 12 năm trước cách đây
mục cha
commit
1d9dda374b
1 tập tin đã thay đổi với 13 bổ sung3 xóa
  1. 13 3
      converse.js

+ 13 - 3
converse.js

@@ -2113,8 +2113,8 @@
 
     converse.onConnected = function (connection) {
         this.connection = connection;
-        this.connection.xmlInput = function (body) { console.log(body); };
-        this.connection.xmlOutput = function (body) { console.log(body); };
+        // this.connection.xmlInput = function (body) { console.log(body); };
+        // this.connection.xmlOutput = function (body) { console.log(body); };
         this.bare_jid = Strophe.getBareJidFromJid(this.connection.jid);
         this.domain = Strophe.getDomainFromJid(this.connection.jid);
         this.features = new this.Features();
@@ -2132,7 +2132,17 @@
         this.rosterview = new this.RosterView({'model':this.roster});
 
         this.xmppstatusview = new this.XMPPStatusView({'model': this.xmppstatus}).render();
-        this.xmppstatus.fetch();
+        this.xmppstatus.fetch({
+            success: $.proxy(function (xmppstatus, resp) {
+                if (!xmppstatus.get('fullname')) {
+                    this.getVCard(
+                        null, // No 'to' attr when getting one's own vCard
+                        $.proxy(function (jid, fullname, image, image_type, url) {
+                            this.xmppstatus.set({'fullname': fullname});
+                        }, this));
+                }
+            }, this)
+        });
 
         this.connection.addHandler(
             $.proxy(this.roster.subscribeToSuggestedItems, this.roster),