Browse Source

prevent double join. fix affiliation typo

master
Philipp Hancke 11 years ago
parent
commit
3d25294354
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      muc.js

+ 7
- 2
muc.js View File

7
     roomjid: null,
7
     roomjid: null,
8
     myroomjid: null,
8
     myroomjid: null,
9
     members: {},
9
     members: {},
10
+    joined: false,
10
     isOwner: false,
11
     isOwner: false,
11
     init: function (conn) {
12
     init: function (conn) {
12
         this.connection = conn;
13
         this.connection = conn;
47
         member.show = $(pres).find('>show').text();
48
         member.show = $(pres).find('>show').text();
48
         member.status = $(pres).find('>status').text();
49
         member.status = $(pres).find('>status').text();
49
         var tmp = $(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>item');
50
         var tmp = $(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>item');
50
-        member.affilication = tmp.attr('affiliation');
51
+        member.affiliation = tmp.attr('affiliation');
51
         member.role = tmp.attr('role');
52
         member.role = tmp.attr('role');
52
         if (from == this.myroomjid) {
53
         if (from == this.myroomjid) {
53
-            $(document).trigger('joined.muc', [from, member]);
54
+            if (member.affiliation == 'owner') this.isOwner = true;
55
+            if (!this.joined) {
56
+                this.joined = true;
57
+                $(document).trigger('joined.muc', [from, member]);
58
+            }
54
         } else if (this.members[from] === undefined) {
59
         } else if (this.members[from] === undefined) {
55
             // new participant
60
             // new participant
56
             this.members[from] = member;
61
             this.members[from] = member;

Loading…
Cancel
Save