Implement well-known support

This commit is contained in:
Christian Pauly 2020-05-16 08:43:27 +02:00
parent cf70aa37cf
commit ac63607f4a
5 changed files with 42 additions and 6 deletions

View File

@ -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:

View File

@ -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: <Widget>[
@ -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,

View File

@ -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<Login> {
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<Login> {
readOnly: loading,
autocorrect: false,
autofocus: true,
onChanged: (t) => _checkWellKnownWithCoolDown(t, context),
controller: usernameController,
decoration: InputDecoration(
hintText:

View File

@ -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"

View File

@ -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