Set Jitsi instance from well-known
This commit is contained in:
parent
f219a69285
commit
ec52badcf3
|
@ -44,6 +44,7 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||
if (success != false) {
|
||||
await Navigator.of(context).push(AppRoute(Login(
|
||||
username: homeserver,
|
||||
wellknown: wellknown,
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
|
@ -57,7 +58,9 @@ class _HomeserverPickerState extends State<HomeserverPicker> {
|
|||
? 'https://${Uri.parse(wellknown.mHomeserver.baseUrl).host}'
|
||||
: homeserver));
|
||||
if (success != false) {
|
||||
await Navigator.of(context).push(AppRoute(SignUp()));
|
||||
await Navigator.of(context).push(AppRoute(SignUp(
|
||||
wellknown: wellknown,
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ import 'package:flutter/material.dart';
|
|||
import 'chat_list.dart';
|
||||
|
||||
class Login extends StatefulWidget {
|
||||
Login({Key key, String this.username: null}) : super(key: key);
|
||||
Login(
|
||||
{Key key,
|
||||
String this.username: null,
|
||||
WellKnownInformations this.wellknown: null})
|
||||
: super(key: key);
|
||||
|
||||
final String username;
|
||||
final WellKnownInformations wellknown;
|
||||
|
||||
@override
|
||||
_LoginState createState() => _LoginState();
|
||||
|
@ -28,6 +33,7 @@ class _LoginState extends State<Login> {
|
|||
String passwordError;
|
||||
bool loading = false;
|
||||
bool showPassword = false;
|
||||
WellKnownInformations newWellknown;
|
||||
|
||||
void login(BuildContext context) async {
|
||||
var matrix = Matrix.of(context);
|
||||
|
@ -72,6 +78,29 @@ class _LoginState extends State<Login> {
|
|||
}
|
||||
}
|
||||
setState(() => loading = false);
|
||||
if (newWellknown != null) {
|
||||
if (newWellknown.jitsiHomeserver?.baseUrl != null) {
|
||||
if (!newWellknown.jitsiHomeserver.baseUrl.startsWith('https://')) {
|
||||
newWellknown.jitsiHomeserver.baseUrl =
|
||||
'https://${newWellknown.jitsiHomeserver.baseUrl}';
|
||||
}
|
||||
Matrix.of(context).store.setItem('chat.fluffy.jitsi_instance',
|
||||
'https://${Uri.parse(newWellknown.jitsiHomeserver.baseUrl).host}/');
|
||||
Matrix.of(context).jitsiInstance =
|
||||
'https://${Uri.parse(newWellknown.jitsiHomeserver.baseUrl).host}/';
|
||||
}
|
||||
} else if (widget.wellknown != null) {
|
||||
if (widget.wellknown.jitsiHomeserver?.baseUrl != null) {
|
||||
if (!widget.wellknown.jitsiHomeserver.baseUrl.startsWith('https://')) {
|
||||
widget.wellknown.jitsiHomeserver.baseUrl =
|
||||
'https://${widget.wellknown.jitsiHomeserver.baseUrl}';
|
||||
}
|
||||
Matrix.of(context).store.setItem('chat.fluffy.jitsi_instance',
|
||||
'https://${Uri.parse(widget.wellknown.jitsiHomeserver.baseUrl).host}/');
|
||||
Matrix.of(context).jitsiInstance =
|
||||
'https://${Uri.parse(widget.wellknown.jitsiHomeserver.baseUrl).host}/';
|
||||
}
|
||||
}
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()), (r) => false);
|
||||
}
|
||||
|
@ -100,8 +129,10 @@ class _LoginState extends State<Login> {
|
|||
Matrix.of(context).client.checkServer(newDomain));
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
newWellknown = wellKnownInformations;
|
||||
} catch (e) {
|
||||
setState(() => usernameError = e.toString());
|
||||
newWellknown = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ import 'package:flutter/material.dart';
|
|||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class SignUp extends StatefulWidget {
|
||||
SignUp({Key key, WellKnownInformations this.wellknown: null})
|
||||
: super(key: key);
|
||||
|
||||
final WellKnownInformations wellknown;
|
||||
|
||||
@override
|
||||
_SignUpState createState() => _SignUpState();
|
||||
}
|
||||
|
@ -60,8 +65,12 @@ class _SignUpState extends State<SignUp> {
|
|||
setState(() => loading = false);
|
||||
await Navigator.of(context).push(
|
||||
AppRoute(
|
||||
SignUpPassword(preferredUsername,
|
||||
avatar: avatar, displayname: usernameController.text),
|
||||
SignUpPassword(
|
||||
preferredUsername,
|
||||
avatar: avatar,
|
||||
displayname: usernameController.text,
|
||||
wellknown: widget.wellknown,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ class SignUpPassword extends StatefulWidget {
|
|||
final File avatar;
|
||||
final String username;
|
||||
final String displayname;
|
||||
const SignUpPassword(this.username, {this.avatar, this.displayname});
|
||||
final WellKnownInformations wellknown;
|
||||
const SignUpPassword(this.username,
|
||||
{this.avatar, this.displayname, this.wellknown});
|
||||
@override
|
||||
_SignUpPasswordState createState() => _SignUpPasswordState();
|
||||
}
|
||||
|
@ -108,6 +110,18 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
BotToast.showText(text: L10n.of(context).couldNotSetAvatar);
|
||||
}
|
||||
}
|
||||
if (widget.wellknown != null) {
|
||||
if (widget.wellknown.jitsiHomeserver?.baseUrl != null) {
|
||||
if (!widget.wellknown.jitsiHomeserver.baseUrl.startsWith('https://')) {
|
||||
widget.wellknown.jitsiHomeserver.baseUrl =
|
||||
'https://${widget.wellknown.jitsiHomeserver.baseUrl}';
|
||||
}
|
||||
Matrix.of(context).store.setItem('chat.fluffy.jitsi_instance',
|
||||
'https://${Uri.parse(widget.wellknown.jitsiHomeserver.baseUrl).host}/');
|
||||
Matrix.of(context).jitsiInstance =
|
||||
'https://${Uri.parse(widget.wellknown.jitsiHomeserver.baseUrl).host}/';
|
||||
}
|
||||
}
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()), (r) => false);
|
||||
setState(() => loading = false);
|
||||
|
|
Loading…
Reference in a new issue