Răsfoiți Sursa

Always clear messages and occupants cache before (re)entering a room

JC Brand 6 ani în urmă
părinte
comite
7511d8c35e
1 a modificat fișierele cu 7 adăugiri și 4 ștergeri
  1. 7 4
      src/headless/converse-muc.js

+ 7 - 4
src/headless/converse-muc.js

@@ -231,6 +231,11 @@ converse.plugins.add('converse-muc', {
 
             async enterRoom () {
                 if (this.get('connection_status') !==  converse.ROOMSTATUS.ENTERED) {
+                    // We're not restoring a room from cache, so let's clear
+                    // the cache (which might be stale).
+                    this.clearMessages();
+                    this.clearOccupants();
+
                     await this.getRoomFeatures();
                     if (!u.isPersistableModel(this)) {
                         // XXX: Happens during tests, nothing to do if this
@@ -264,13 +269,11 @@ converse.plugins.add('converse-muc', {
                 }
             },
 
-            onReconnection () {
+            async onReconnection () {
                 this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
-                this.clearMessages();
-                this.clearOccupants();
                 this.registerHandlers();
+                await this.enterRoom();
                 this.announceReconnection();
-                this.enterRoom();
             },
 
             initFeatures () {