소스 검색

Fixed an error that appears when unload event is triggered

This happens when you load a page with converse and do not login to
the chat. It can be tested in converse.org preserving logs while
navigating to another page.
Inside clearSession there's a call to roster which is not initalized
and also another one to controlbox.save which is not set so it fails
with an url error during sync.
Guillermo Bonvehí 10 년 전
부모
커밋
71ea60e44a
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      converse.js

+ 6 - 3
converse.js

@@ -569,10 +569,13 @@
         };
 
         this.clearSession = function () {
-            this.roster.browserStorage._clear();
+            if (this.roster) {
+                this.roster.browserStorage._clear();
+            }
             this.session.browserStorage._clear();
-            var controlbox = converse.chatboxes.get('controlbox');
-            controlbox.save({'connected': false});
+            if (converse.connection.connected) {
+                converse.chatboxes.get('controlbox').save({'connected': false});
+            }
         };
 
         this.setSession = function () {