Procházet zdrojové kódy

Throw more helpful error when there's no connection

JC Brand před 7 roky
rodič
revize
dffc6fbb50
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6 1
      src/converse-mam.js

+ 6 - 1
src/converse-mam.js

@@ -333,7 +333,12 @@
                 /* Extend default converse.js API to add methods specific to MAM
                  */
                 'archive': {
-                    'query': _converse.queryForArchivedMessages.bind(_converse)
+                    'query': function () {
+                        if (!_converse.api.connection.connected()) {
+                            throw new Error('Can\'t call `api.archive.query` before having established an XMPP session');
+                        }
+                        return _converse.queryForArchivedMessages.apply(this, arguments);
+                    }
                 }
             });