Only change homeserver info when username changed

parent 442292e3
......@@ -38,19 +38,12 @@ class UsernamePageState extends State<UsernamePage> {
StreamSubscription subscription;
@override
void initState() {
super.initState();
usernameController.addListener(() {
final text = usernameController.text;
final split = text.split(':');
if (split.length == 2) {
String server = split[1];
bloc.setHomeserverUrl(server, allowMistake: true);
}
});
void onUsernameChanged(String username) {
final split = username.split(':');
if (split.length == 2) {
String server = split[1];
bloc.setHomeserverUrl(server, allowMistake: true);
}
subscription = bloc.isUsernameAvailable.listen((state) {
if (state == RequestState.success) {
......@@ -66,6 +59,11 @@ class UsernamePageState extends State<UsernamePage> {
});
}
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
......@@ -141,6 +139,7 @@ class UsernamePageState extends State<UsernamePage> {
textCapitalization: TextCapitalization.none,
autocorrect: false,
onSubmitted: (_) => _next(context),
onChanged: onUsernameChanged,
decoration: InputDecoration(
filled: true,
prefixText: '@',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment