瀏覽代碼

Bugfix. Avoid calling `this.authenticate` twice in one method

JC Brand 3 年之前
父節點
當前提交
e9ae5306e3
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10 5
      src/plugins/controlbox/loginform.js

+ 10 - 5
src/plugins/controlbox/loginform.js

@@ -29,13 +29,18 @@ class LoginForm extends CustomElement {
         if (api.settings.get('bosh_service_url') ||
                 api.settings.get('websocket_url') ||
                 this.model.get('show_connection_url_input')) {
-            this.authenticate(ev);
-        }
-        await this.discoverConnectionMethods(ev);
-        if (api.settings.get('bosh_service_url') || api.settings.get('websocket_url')) {
+            // The connection class will still try to discover XEP-0156 connection methods
             this.authenticate(ev);
         } else {
-            this.model.set('show_connection_url_input', true);
+            // We don't have a connection URL available, so we try here to discover
+            // XEP-0156 connection methods now, and if not found we present the user
+            // with the option to enter their own connection URL
+            await this.discoverConnectionMethods(ev);
+            if (api.settings.get('bosh_service_url') || api.settings.get('websocket_url')) {
+                this.authenticate(ev);
+            } else {
+                this.model.set('show_connection_url_input', true);
+            }
         }
     }