summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-10-05 19:20:14 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-10-05 19:20:22 +0200
commitaed1440d267f043cfd5bc632cff3758f7cd4bf1e (patch)
tree2898b8c9bd9a07fa4dcd64abcc9c0bfdba244249 /src
parentFix userprofile on roomlist (diff)
downloadnheko-aed1440d267f043cfd5bc632cff3758f7cd4bf1e.tar.xz
Don't let old server lookups overwrite new ones
Diffstat (limited to 'src')
-rw-r--r--src/LoginPage.cpp8
-rw-r--r--src/RegisterPage.cpp6
2 files changed, 12 insertions, 2 deletions
diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp
index b288066b..567e8c82 100644
--- a/src/LoginPage.cpp
+++ b/src/LoginPage.cpp
@@ -108,7 +108,13 @@ LoginPage::onMatrixIdEntered()
         emit homeserverChanged();
 
         http::client()->well_known(
-          [this](const mtx::responses::WellKnown &res, mtx::http::RequestErr err) {
+          [this, orginal_hostname = user.hostname()](const mtx::responses::WellKnown &res,
+                                                     mtx::http::RequestErr err) {
+              // Ignore if server changed
+              auto currentUser = parse<User>(mxid_.toStdString());
+              if (currentUser.hostname() != orginal_hostname)
+                  return;
+
               if (err) {
                   if (err->status_code == 404) {
                       nhlog::net()->info("Autodiscovery: No .well-known.");
diff --git a/src/RegisterPage.cpp b/src/RegisterPage.cpp
index 2285ac29..82302858 100644
--- a/src/RegisterPage.cpp
+++ b/src/RegisterPage.cpp
@@ -67,7 +67,11 @@ RegisterPage::setServer(const QString &server)
     emit lookingUpHsChanged();
 
     http::client()->well_known(
-      [this](const mtx::responses::WellKnown &res, mtx::http::RequestErr err) {
+      [this, prevServer = server](const mtx::responses::WellKnown &res, mtx::http::RequestErr err) {
+          // server changed in between
+          if (lastServer != prevServer)
+              return;
+
           if (err) {
               if (err->status_code == 404) {
                   nhlog::net()->info("Autodiscovery: No .well-known.");