mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 03:45:12 +00:00
fix: Allow fallback to previous url if there is no homeserver on the mxid domain
This commit is contained in:
parent
7ac90bb3f0
commit
737f78dd11
2 changed files with 32 additions and 1 deletions
|
@ -1351,6 +1351,14 @@
|
|||
"type": "text",
|
||||
"placeholders": {}
|
||||
},
|
||||
"noMatrixServer": "{server1} is no matrix server, use {server2} instead?",
|
||||
"@noMatrixServer": {
|
||||
"type": "text",
|
||||
"placeholders": {
|
||||
"server1": {},
|
||||
"server2": {}
|
||||
}
|
||||
},
|
||||
"noMegolmBootstrap": "Please turn on online key backup from within Element instead.",
|
||||
"@noMegolmBootstrap": {
|
||||
"type": "text",
|
||||
|
|
|
@ -117,10 +117,33 @@ class LoginController extends State<Login> {
|
|||
.setItem(SettingKeys.jitsiInstance, jitsi);
|
||||
AppConfig.jitsiInstance = jitsi;
|
||||
}
|
||||
final oldHomeserver = Matrix.of(context).client.homeserver;
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.checkHomeserver(newDomain),
|
||||
// do nothing if we error, we'll handle it below
|
||||
future: () => Matrix.of(context)
|
||||
.client
|
||||
.checkHomeserver(newDomain)
|
||||
.catchError((e) => null),
|
||||
);
|
||||
if (Matrix.of(context).client.homeserver == null) {
|
||||
Matrix.of(context).client.homeserver = oldHomeserver;
|
||||
// okay, the server we checked does not appear to be a matrix server
|
||||
Logs().v(
|
||||
'$newDomain is not running a homeserver, asking to use $oldHomeserver');
|
||||
final dialogResult = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
message: L10n.of(context).noMatrixServer(newDomain, oldHomeserver),
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
);
|
||||
if (dialogResult == OkCancelResult.ok) {
|
||||
setState(() => usernameError = null);
|
||||
} else {
|
||||
Navigator.of(context, rootNavigator: false).pop();
|
||||
}
|
||||
}
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue