Sfoglia il codice sorgente

Destroy devicelist if we can't fetch the devices for it.

Otherwise Converse will try to fetch the devices again and again upon
page refresh.
JC Brand 6 anni fa
parent
commit
98fee37a41
2 ha cambiato i file con 24 aggiunte e 4 eliminazioni
  1. 14 2
      dist/converse.js
  2. 10 2
      src/converse-omemo.js

+ 14 - 2
dist/converse.js

@@ -56981,7 +56981,19 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
             this.devices.fetch({
               'success': async collection => {
                 if (collection.length === 0) {
-                  const ids = await this.fetchDevicesFromServer();
+                  let ids;
+
+                  try {
+                    ids = await this.fetchDevicesFromServer();
+                  } catch (e) {
+                    _converse.log(`Could not fetch devices for ${this.get('jid')}`);
+
+                    _converse.log(e, Strophe.LogLevel.ERROR);
+
+                    this.destroy();
+                    return resolve(e);
+                  }
+
                   await this.publishCurrentDevice(ids);
                 }
 
@@ -56990,7 +57002,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
               'error': e => {
                 _converse.log(e, Strophe.LogLevel.ERROR);
 
-                resolve();
+                resolve(e);
               }
             });
           });

+ 10 - 2
src/converse-omemo.js

@@ -955,14 +955,22 @@ converse.plugins.add('converse-omemo', {
                         this.devices.fetch({
                             'success': async collection => {
                                 if (collection.length === 0) {
-                                    const ids = await this.fetchDevicesFromServer()
+                                    let ids;
+                                    try {
+                                        ids = await this.fetchDevicesFromServer()
+                                    } catch (e) {
+                                        _converse.log(`Could not fetch devices for ${this.get('jid')}`);
+                                        _converse.log(e, Strophe.LogLevel.ERROR);
+                                        this.destroy();
+                                        return resolve(e);
+                                    }
                                     await this.publishCurrentDevice(ids);
                                 }
                                 resolve();
                             },
                             'error': e => {
                                 _converse.log(e, Strophe.LogLevel.ERROR);
-                                resolve();
+                                resolve(e);
                             }
                         });
                     });