diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e42472..dd6c3b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Implement image viewer - Implement room pills - New chat appBar showing presences and room avatars +- Implement well-known support # Version 0.13.2 - 2020-05-13 ### Fixes: diff --git a/lib/views/chat.dart b/lib/views/chat.dart index 6aa65f0..f9eb3a3 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -395,10 +395,12 @@ class _ChatState extends State<_Chat> { ChatDetails(room), ), ), - title: Text(room.getLocalizedDisplayname(L10n.of(context)),maxLines: 1), + title: Text(room.getLocalizedDisplayname(L10n.of(context)), + maxLines: 1), subtitle: typingText.isEmpty ? Text( - room.getLocalizedStatus(context),maxLines: 1, + room.getLocalizedStatus(context), + maxLines: 1, ) : Row( children: [ @@ -407,7 +409,8 @@ class _ChatState extends State<_Chat> { size: 13), SizedBox(width: 4), Text( - typingText,maxLines: 1, + typingText, + maxLines: 1, style: TextStyle( color: Theme.of(context).primaryColor, fontStyle: FontStyle.italic, diff --git a/lib/views/login.dart b/lib/views/login.dart index 8b49e7e..4a3f406 100644 --- a/lib/views/login.dart +++ b/lib/views/login.dart @@ -1,6 +1,8 @@ +import 'dart:async'; import 'dart:math'; import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/utils/app_route.dart'; @@ -70,6 +72,35 @@ class _LoginState extends State { AppRoute.defaultRoute(context, ChatListView()), (r) => false); } + Timer _coolDown; + + void _checkWellKnownWithCoolDown(String userId, BuildContext context) async { + _coolDown?.cancel(); + _coolDown = Timer( + Duration(seconds: 1), + () => _checkWellKnown(userId, context), + ); + } + + void _checkWellKnown(String userId, BuildContext context) async { + setState(() => usernameError = null); + if (!userId.isValidMatrixId) return; + try { + final wellKnownInformations = await Matrix.of(context) + .client + .getWellKnownInformationsByUserId(userId); + final newDomain = wellKnownInformations.mHomeserver?.baseUrl; + if ((newDomain?.isNotEmpty ?? false) && + newDomain != Matrix.of(context).client.homeserver) { + await SimpleDialogs(context).tryRequestWithErrorToast( + Matrix.of(context).client.checkServer(newDomain)); + setState(() => usernameError = null); + } + } catch (e) { + setState(() => usernameError = e.toString()); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -98,6 +129,7 @@ class _LoginState extends State { readOnly: loading, autocorrect: false, autofocus: true, + onChanged: (t) => _checkWellKnownWithCoolDown(t, context), controller: usernameController, decoration: InputDecoration( hintText: diff --git a/pubspec.lock b/pubspec.lock index bf9d073..87a490f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -147,8 +147,8 @@ packages: dependency: "direct main" description: path: "." - ref: e8436198bbf77ad6d13d852d13e73e745a5df0cf - resolved-ref: e8436198bbf77ad6d13d852d13e73e745a5df0cf + ref: "7c0d84b27f59adadf47f73394d5d2b53d3d3e773" + resolved-ref: "7c0d84b27f59adadf47f73394d5d2b53d3d3e773" url: "https://gitlab.com/famedly/famedlysdk.git" source: git version: "0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 9e4eb96..d280a64 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: famedlysdk: git: url: https://gitlab.com/famedly/famedlysdk.git - ref: e8436198bbf77ad6d13d852d13e73e745a5df0cf + ref: 7c0d84b27f59adadf47f73394d5d2b53d3d3e773 localstorage: ^3.0.1+4 bubble: ^1.1.9+1