From fa543e93b887e943a270d2bc439e0298005963ff Mon Sep 17 00:00:00 2001 From: Krille Date: Fri, 22 Dec 2023 19:27:19 +0100 Subject: [PATCH] chore: Follow up status feature --- lib/pages/chat_list/chat_list_body.dart | 7 ++++--- lib/pages/chat_list/status_msg_list.dart | 15 ++++++++++++--- lib/widgets/matrix.dart | 7 +++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 4bed79f1..0989285f 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -153,9 +153,10 @@ class ChatListViewBody extends StatelessWidget { ), ), ], - StatusMessageList( - onStatusEdit: controller.setStatus, - ), + if (!controller.isSearchMode) + StatusMessageList( + onStatusEdit: controller.setStatus, + ), const ConnectionStatusHeader(), AnimatedContainer( height: controller.isTorBrowser ? 64 : 0, diff --git a/lib/pages/chat_list/status_msg_list.dart b/lib/pages/chat_list/status_msg_list.dart index a955d888..40107412 100644 --- a/lib/pages/chat_list/status_msg_list.dart +++ b/lib/pages/chat_list/status_msg_list.dart @@ -18,7 +18,7 @@ class StatusMessageList extends StatelessWidget { super.key, }); - static const double height = 108; + static const double height = 116; void _onStatusTab(BuildContext context, Profile profile) { final client = Matrix.of(context).client; @@ -37,6 +37,8 @@ class StatusMessageList extends StatelessWidget { @override Widget build(BuildContext context) { final client = Matrix.of(context).client; + final interestingPresences = client.interestingPresences; + return StreamBuilder( stream: client.onSync.stream.rateLimit(const Duration(seconds: 3)), builder: (context, snapshot) { @@ -44,6 +46,10 @@ class StatusMessageList extends StatelessWidget { duration: FluffyThemes.animationDuration, curve: Curves.easeInOut, child: FutureBuilder( + initialData: interestingPresences + // ignore: deprecated_member_use + .map((userId) => client.presences[userId]) + .whereType(), future: Future.wait( client.interestingPresences .map((userId) => client.fetchCurrentPresence(userId)), @@ -69,7 +75,7 @@ class StatusMessageList extends StatelessWidget { return SizedBox( height: StatusMessageList.height, child: ListView.builder( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.all(8), scrollDirection: Axis.horizontal, itemCount: presences.length, itemBuilder: (context, i) => PresenceAvatar( @@ -101,7 +107,7 @@ class PresenceAvatar extends StatelessWidget { @override Widget build(BuildContext context) { - final avatarSize = height - 16 - 16; + final avatarSize = height - 16 - 16 - 8; final client = Matrix.of(context).client; return FutureBuilder( future: client.getProfileFromUserId(presence.userid), @@ -162,6 +168,9 @@ class PresenceAvatar extends StatelessWidget { profile ?? Profile(userId: presence.userid), ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), child: const Icon( Icons.add_outlined, size: 16, diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index ec529db1..a357e99a 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -419,8 +419,11 @@ class MatrixState extends State with WidgetsBindingObserver { Logs().v('AppLifecycleState = $state'); final foreground = state != AppLifecycleState.detached && state != AppLifecycleState.paused; - client.backgroundSync = foreground; - client.requestHistoryOnLimitedTimeline = !foreground; + client.syncPresence = foreground ? null : PresenceType.unavailable; + if (PlatformInfos.isMobile) { + client.backgroundSync = foreground; + client.requestHistoryOnLimitedTimeline = !foreground; + } } void initSettings() {