Don't let old server lookups overwrite new ones

pull/1161/head
Nicolas Werner 2 years ago
parent d70a344a4d
commit aed1440d26
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 8
      src/LoginPage.cpp
  2. 6
      src/RegisterPage.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.");

@ -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.");

Loading…
Cancel
Save