Browse Source

feat: Clean up immediately when room is not joined.

When receiving error like max occupants reached we have not joined the room, and there is no point of sending presence unavailable and check and clean after 5 secs.
master
damencho 2 years ago
parent
commit
6b71d39b21
1 changed files with 12 additions and 4 deletions
  1. 12
    4
      modules/xmpp/ChatRoom.js

+ 12
- 4
modules/xmpp/ChatRoom.js View File

1853
                 }
1853
                 }
1854
             };
1854
             };
1855
 
1855
 
1856
-            timeout = setTimeout(() => onMucLeft(true), 5000);
1856
+            if (this.joined) {
1857
+                timeout = setTimeout(() => onMucLeft(true), 5000);
1857
 
1858
 
1858
-            this.clean();
1859
-            this.eventEmitter.on(XMPPEvents.MUC_LEFT, onMucLeft);
1860
-            this.doLeave(reason);
1859
+                this.clean();
1860
+                this.eventEmitter.on(XMPPEvents.MUC_LEFT, onMucLeft);
1861
+                this.doLeave(reason);
1862
+            } else {
1863
+                // we are clearing up, and we haven't joined the room
1864
+                // there is no point of sending presence unavailable and check for timeout
1865
+                // let's just clean
1866
+                this.connection.emuc.doLeave(this.roomjid);
1867
+                this.clean();
1868
+            }
1861
         }));
1869
         }));
1862
 
1870
 
1863
         return Promise.allSettled(promises);
1871
         return Promise.allSettled(promises);

Loading…
Cancel
Save