|
@@ -1857,27 +1857,24 @@ export default class ChatRoom extends Listenable {
|
1857
|
1857
|
this.lobby?.lobbyRoom && promises.push(this.lobby.leave());
|
1858
|
1858
|
|
1859
|
1859
|
promises.push(new Promise((resolve, reject) => {
|
1860
|
|
- const timeout = setTimeout(() => onMucLeft(true), 5000);
|
1861
|
|
- const eventEmitter = this.eventEmitter;
|
|
1860
|
+ let timeout = -1;
|
1862
|
1861
|
|
1863
|
|
- this.clean();
|
1864
|
|
-
|
1865
|
|
- /**
|
1866
|
|
- *
|
1867
|
|
- * @param doReject
|
1868
|
|
- */
|
1869
|
|
- function onMucLeft(doReject = false) {
|
1870
|
|
- eventEmitter.removeListener(XMPPEvents.MUC_LEFT, onMucLeft);
|
|
1862
|
+ const onMucLeft = (doReject = false) => {
|
|
1863
|
+ this.eventEmitter.removeListener(XMPPEvents.MUC_LEFT, onMucLeft);
|
1871
|
1864
|
clearTimeout(timeout);
|
1872
|
1865
|
if (doReject) {
|
1873
|
|
- // the timeout expired
|
1874
|
|
- reject(new Error('The timeout for the confirmation about '
|
1875
|
|
- + 'leaving the room expired.'));
|
|
1866
|
+ // The timeout expired. Make sure we clean the EMUC state.
|
|
1867
|
+ this.connection.emuc.doLeave(this.roomjid);
|
|
1868
|
+ reject(new Error('The timeout for the confirmation about leaving the room expired.'));
|
1876
|
1869
|
} else {
|
1877
|
1870
|
resolve();
|
1878
|
1871
|
}
|
1879
|
|
- }
|
1880
|
|
- eventEmitter.on(XMPPEvents.MUC_LEFT, onMucLeft);
|
|
1872
|
+ };
|
|
1873
|
+
|
|
1874
|
+ timeout = setTimeout(() => onMucLeft(true), 5000);
|
|
1875
|
+
|
|
1876
|
+ this.clean();
|
|
1877
|
+ this.eventEmitter.on(XMPPEvents.MUC_LEFT, onMucLeft);
|
1881
|
1878
|
this.doLeave();
|
1882
|
1879
|
}));
|
1883
|
1880
|
|