Explorar o código

Bugfix. Error message wasn't shown when login failed

JC Brand hai 4 meses
pai
achega
96b84ef8cc
Modificáronse 2 ficheiros con 12 adicións e 7 borrados
  1. 5 2
      src/headless/shared/connection/index.js
  2. 7 5
      src/headless/utils/init.js

+ 5 - 2
src/headless/shared/connection/index.js

@@ -391,6 +391,7 @@ export class Connection extends Strophe.Connection {
                 status,
                 __('An error occurred while connecting to the chat server.')
             );
+
         } else if (status === Strophe.Status.CONNECTING) {
             this.setConnectionStatus(status);
         } else if (status === Strophe.Status.AUTHENTICATING) {
@@ -402,16 +403,18 @@ export class Connection extends Strophe.Connection {
             this.setConnectionStatus(status, message);
             this.setDisconnectionCause(status, message, true);
             this.onDisconnected();
+
         } else if (status === Strophe.Status.CONNFAIL) {
             let feedback = message;
             if (message === "host-unknown" || message == "remote-connection-failed") {
-                feedback = __("Sorry, we could not connect to the XMPP host with domain: %1$s",
-                    `\"${Strophe.getDomainFromJid(this.jid)}\"`);
+                feedback = __("We could not connect to %1$s, is your XMPP address correct?",
+                    Strophe.getDomainFromJid(this.jid));
             } else if (message !== undefined && message === Strophe?.ErrorCondition?.NO_AUTH_MECH) {
                 feedback = __("The XMPP server did not offer a supported authentication mechanism");
             }
             this.setConnectionStatus(status, feedback);
             this.setDisconnectionCause(status, message);
+
         } else if (status === Strophe.Status.DISCONNECTING) {
             this.setDisconnectionCause(status, message);
         }

+ 7 - 5
src/headless/utils/init.js

@@ -468,6 +468,7 @@ async function connect (credentials) {
             connection.reset();
         }
         connection.connect(jid.toLowerCase());
+
     } else if (api.settings.get("authentication") === LOGIN) {
         const password = credentials?.password ?? (connection?.pass || api.settings.get("password"));
         if (!password) {
@@ -494,16 +495,17 @@ async function connect (credentials) {
         ) {
             // Store scram keys in scram storage
             const login_info = await savedLoginInfo(jid);
-
             callback =
-                /** @param {string} status */
-                (status) => {
+                /**
+                 * @param {string} status
+                 * @param {string} message
+                 */
+                (status, message) => {
                     const { scram_keys } = connection;
                     if (scram_keys) login_info.save({ scram_keys });
-                    connection.onConnectStatusChanged(status);
+                    connection.onConnectStatusChanged(status, message);
                 };
         }
-
         connection.connect(jid, password, callback);
     }
 }