From 347fa01ff8eeb6048e0a26cea88c6f75ed6abf2f Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 30 Jul 2024 14:01:11 -0400 Subject: [PATCH 1/5] Chat list is shown when rooms are loaded --- lib/pages/chat_list/chat_list.dart | 3 +++ lib/pages/chat_list/chat_list_body.dart | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 8f5515fc4..e4ac86d36 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -909,6 +909,9 @@ class ChatListController extends State Future _waitForFirstSync() async { final client = Matrix.of(context).client; await client.roomsLoading; + // #Pangea + setState(() {}); + // Pangea# await client.accountDataLoading; await client.userDeviceKeysLoading; if (client.prevBatch == null) { diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index b9b388da9..11be0e097 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -187,7 +187,12 @@ class ChatListViewBody extends StatelessWidget { ], ), ), - if (client.prevBatch == null) + // #Pangea + // Only show loading screen if room list is empty + // because it is still loading + // if (client.prevBatch == null) + if (rooms.isEmpty && client.prevBatch == null) + // Pangea# SliverList( delegate: SliverChildBuilderDelegate( (context, i) => Opacity( @@ -245,7 +250,10 @@ class ChatListViewBody extends StatelessWidget { childCount: dummyChatCount, ), ), - if (client.prevBatch != null) + // #Pangea + // if (client.prevBatch != null) + if (rooms.isNotEmpty) + // Pangea# SliverList.builder( itemCount: rooms.length, itemBuilder: (BuildContext context, int i) { From 097417188df2c4aa848440df8b55ecaa163ef483 Mon Sep 17 00:00:00 2001 From: Kelrap Date: Tue, 30 Jul 2024 14:26:26 -0400 Subject: [PATCH 2/5] Move less important syncs to own function --- lib/pages/chat_list/chat_list.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index e4ac86d36..8d49c9478 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -933,8 +933,17 @@ class ChatListController extends State } // #Pangea + _lessImportantSyncs(client); + // Pangea# + if (!mounted) return; + setState(() { + waitForFirstSync = true; + }); + } + + // #Pangea + Future _lessImportantSyncs(Client client) async { if (mounted) { - // TODO try not to await so much GoogleAnalytics.analyticsUserUpdate(client.userID); await pangeaController.subscriptionController.initialize(); await pangeaController.myAnalytics.initialize(); @@ -946,14 +955,9 @@ class ChatListController extends State ErrorHandler.logError( m: "didn't run afterSyncAndFirstLoginInitialization because not mounted", ); - // debugger(when: kDebugMode); } - // Pangea# - if (!mounted) return; - setState(() { - waitForFirstSync = true; - }); } + // Pangea# void cancelAction() { if (selectMode == SelectMode.share) { From b9c9332d28fb3e3cd3502a0815d42e21883624eb Mon Sep 17 00:00:00 2001 From: Kelrap Date: Wed, 31 Jul 2024 15:12:04 -0400 Subject: [PATCH 3/5] Remove unecessary setState --- lib/pages/chat_list/chat_list.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 8d49c9478..8a588d1aa 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -909,9 +909,6 @@ class ChatListController extends State Future _waitForFirstSync() async { final client = Matrix.of(context).client; await client.roomsLoading; - // #Pangea - setState(() {}); - // Pangea# await client.accountDataLoading; await client.userDeviceKeysLoading; if (client.prevBatch == null) { From 8294e1959c2c97caa5ea20e2616dec3aae2e4ffd Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 2 Aug 2024 13:32:23 -0400 Subject: [PATCH 4/5] Fixes input bar spacing issues --- lib/pages/chat/chat_view.dart | 409 ++++++++++++++++++---------------- 1 file changed, 212 insertions(+), 197 deletions(-) diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 9b12f9904..405e16418 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -14,7 +14,6 @@ import 'package:fluffychat/pangea/choreographer/widgets/start_igc_button.dart'; import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart'; import 'package:fluffychat/pangea/widgets/chat/chat_floating_action_button.dart'; import 'package:fluffychat/utils/account_config.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/widgets/chat_settings_popup_menu.dart'; import 'package:fluffychat/widgets/connection_status_header.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -299,216 +298,232 @@ class ChatView extends StatelessWidget { ), ), SafeArea( - child: Column( - children: [ - Expanded( - child: GestureDetector( - onTap: controller.clearSingleSelectedEvent, - child: Builder( - builder: (context) { - if (controller.timeline == null) { - return const Center( - child: CircularProgressIndicator.adaptive( - strokeWidth: 2, - ), - ); - } - return ChatEventList( - controller: controller, - ); - }, - ), - ), - ), - if (controller.room.canSendDefaultMessages && - controller.room.membership == Membership.join) - Container( - margin: EdgeInsets.only( - bottom: bottomSheetPadding, - left: bottomSheetPadding, - right: bottomSheetPadding, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 2.5, - ), - alignment: Alignment.center, - child: Material( - clipBehavior: Clip.hardEdge, - color: Theme.of(context) - .colorScheme - // ignore: deprecated_member_use - .surfaceVariant, - borderRadius: const BorderRadius.all( - Radius.circular(24), + child: + // #Pangea + Stack( + children: [ + // Pangea# + Column( + children: [ + Expanded( + child: GestureDetector( + onTap: controller.clearSingleSelectedEvent, + child: Builder( + builder: (context) { + if (controller.timeline == null) { + return const Center( + child: + CircularProgressIndicator.adaptive( + strokeWidth: 2, + ), + ); + } + return ChatEventList( + controller: controller, + ); + }, + ), ), - child: controller.room.isAbandonedDMRoom == true - ? Row( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - // #Pangea - if (controller.room.isRoomAdmin) - TextButton.icon( - style: TextButton.styleFrom( - padding: const EdgeInsets.all( - 16, - ), - foregroundColor: Theme.of(context) - .colorScheme - .error, - ), - icon: const Icon( - Icons.archive_outlined, - ), - onPressed: controller.archiveChat, - label: Text( - L10n.of(context)!.archive, - ), - ), - // Pangea# - TextButton.icon( - style: TextButton.styleFrom( - padding: const EdgeInsets.all( - 16, - ), - foregroundColor: Theme.of(context) - .colorScheme - .error, - ), - icon: const Icon( + ), + if (controller.room.canSendDefaultMessages && + controller.room.membership == Membership.join) + Container( + margin: EdgeInsets.only( + bottom: bottomSheetPadding, + left: bottomSheetPadding, + right: bottomSheetPadding, + ), + constraints: const BoxConstraints( + maxWidth: FluffyThemes.columnWidth * 2.5, + ), + alignment: Alignment.center, + child: Material( + clipBehavior: Clip.hardEdge, + color: Theme.of(context) + .colorScheme + // ignore: deprecated_member_use + .surfaceVariant, + borderRadius: const BorderRadius.all( + Radius.circular(24), + ), + child: controller.room.isAbandonedDMRoom == + true + ? Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ // #Pangea - // Icons.archive_outlined, - Icons.arrow_forward, + if (controller.room.isRoomAdmin) + TextButton.icon( + style: TextButton.styleFrom( + padding: const EdgeInsets.all( + 16, + ), + foregroundColor: + Theme.of(context) + .colorScheme + .error, + ), + icon: const Icon( + Icons.archive_outlined, + ), + onPressed: + controller.archiveChat, + label: Text( + L10n.of(context)!.archive, + ), + ), // Pangea# - ), - onPressed: controller.leaveChat, - label: Text( - L10n.of(context)!.leave, - ), - ), - TextButton.icon( - style: TextButton.styleFrom( - padding: const EdgeInsets.all( - 16, + TextButton.icon( + style: TextButton.styleFrom( + padding: const EdgeInsets.all( + 16, + ), + foregroundColor: + Theme.of(context) + .colorScheme + .error, + ), + icon: const Icon( + // #Pangea + // Icons.archive_outlined, + Icons.arrow_forward, + // Pangea# + ), + onPressed: controller.leaveChat, + label: Text( + L10n.of(context)!.leave, + ), ), - ), - icon: const Icon( - Icons.forum_outlined, - ), - onPressed: controller.recreateChat, - label: Text( - L10n.of(context)!.reopenChat, - ), - ), - ], - ) - : - // #Pangea - null, - // Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // const ConnectionStatusHeader(), - // ITBar( - // choreographer: - // controller.choreographer, - // ), - // ReactionsPicker(controller), - // ReplyDisplay(controller), - // ChatInputRow(controller), - // ChatEmojiPicker(controller), - // ], - // ), - // Pangea# + TextButton.icon( + style: TextButton.styleFrom( + padding: const EdgeInsets.all( + 16, + ), + ), + icon: const Icon( + Icons.forum_outlined, + ), + onPressed: + controller.recreateChat, + label: Text( + L10n.of(context)!.reopenChat, + ), + ), + ], + ) + : + // #Pangea + null, + // Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // const ConnectionStatusHeader(), + // ITBar( + // choreographer: + // controller.choreographer, + // ), + // ReactionsPicker(controller), + // ReplyDisplay(controller), + // ChatInputRow(controller), + // ChatEmojiPicker(controller), + // ], + // ), + // Pangea# + ), + ), + // #Pangea + // Keep messages above minimum input bar height + const SizedBox( + height: 60, ), - ), - // #Pangea - // Keep messages above minimum input bar height - SizedBox( - height: (PlatformInfos.isMobile ? 30 : 60), + // Pangea# + ], ), - // Pangea# - ], - ), - ), - // #Pangea - // if (controller.dragging) - // Container( - // color: Theme.of(context) - // .scaffoldBackgroundColor - // .withOpacity(0.9), - // alignment: Alignment.center, - // child: const Icon( - // Icons.upload_outlined, - // size: 100, - // ), - // ), - Positioned( - left: 0, - right: 0, - bottom: 16, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (!controller.selectMode) - Container( - margin: EdgeInsets.only( - bottom: 10, - left: bottomSheetPadding, - right: bottomSheetPadding, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 2.4, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - StartIGCButton( - controller: controller, + // #Pangea + Positioned( + left: 0, + right: 0, + bottom: 16, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (!controller.selectMode) + Container( + margin: EdgeInsets.only( + bottom: 10, + left: bottomSheetPadding, + right: bottomSheetPadding, + ), + constraints: const BoxConstraints( + maxWidth: FluffyThemes.columnWidth * 2.4, + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + StartIGCButton( + controller: controller, + ), + ChatFloatingActionButton( + controller: controller, + ), + ], + ), ), - ChatFloatingActionButton( - controller: controller, + Container( + margin: EdgeInsets.only( + bottom: bottomSheetPadding, + left: bottomSheetPadding, + right: bottomSheetPadding, ), - ], - ), - ), - Container( - margin: EdgeInsets.only( - bottom: bottomSheetPadding, - left: bottomSheetPadding, - right: bottomSheetPadding, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 2.5, - ), - alignment: Alignment.center, - child: Material( - clipBehavior: Clip.hardEdge, - color: Theme.of(context) - .colorScheme - .surfaceContainerHighest, - borderRadius: const BorderRadius.all( - Radius.circular(24), - ), - child: Column( - children: [ - const ConnectionStatusHeader(), - ITBar( - choreographer: controller.choreographer, + constraints: const BoxConstraints( + maxWidth: FluffyThemes.columnWidth * 2.5, ), - ReactionsPicker(controller), - ReplyDisplay(controller), - ChatInputRow(controller), - ChatEmojiPicker(controller), - ], - ), + alignment: Alignment.center, + child: Material( + clipBehavior: Clip.hardEdge, + color: Theme.of(context) + .colorScheme + .surfaceContainerHighest, + borderRadius: const BorderRadius.all( + Radius.circular(24), + ), + child: Column( + children: [ + const ConnectionStatusHeader(), + ITBar( + choreographer: controller.choreographer, + ), + ReactionsPicker(controller), + ReplyDisplay(controller), + ChatInputRow(controller), + ChatEmojiPicker(controller), + ], + ), + ), + ), + ], ), ), + // Pangea# ], ), + // #Pangea + // if (controller.dragging) + // Container( + // color: Theme.of(context) + // .scaffoldBackgroundColor + // .withOpacity(0.9), + // alignment: Alignment.center, + // child: const Icon( + // Icons.upload_outlined, + // size: 100, + // ), + // ), + // Pangea# ), - // Pangea# ], ), ); From 6cc07d5c3858f8768afbb1875daffb92461c889d Mon Sep 17 00:00:00 2001 From: ggurdin Date: Mon, 5 Aug 2024 09:39:04 -0400 Subject: [PATCH 5/5] changed condition to wait for next sync in stream in waitforfirstsync to better reflect whether the first sync has come through or not --- lib/pages/chat_list/chat_list.dart | 14 ++++++++------ lib/pages/chat_list/chat_list_body.dart | 12 ++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 8a588d1aa..ec34a5b81 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -911,11 +911,12 @@ class ChatListController extends State await client.roomsLoading; await client.accountDataLoading; await client.userDeviceKeysLoading; - if (client.prevBatch == null) { + // #Pangea + // See here for explanation of this change: https://github.com/pangeachat/client/pull/539 + // if (client.prevBatch == null) { + if (client.onSync.value?.nextBatch == null) { + // Pangea# await client.onSync.stream.first; - // #Pangea - pangeaController.startChatWithBotIfNotPresent(); - //Pangea# // Display first login bootstrap if enabled // #Pangea @@ -930,7 +931,7 @@ class ChatListController extends State } // #Pangea - _lessImportantSyncs(client); + await _initPangeaControllers(client); // Pangea# if (!mounted) return; setState(() { @@ -939,9 +940,10 @@ class ChatListController extends State } // #Pangea - Future _lessImportantSyncs(Client client) async { + Future _initPangeaControllers(Client client) async { if (mounted) { GoogleAnalytics.analyticsUserUpdate(client.userID); + pangeaController.startChatWithBotIfNotPresent(); await pangeaController.subscriptionController.initialize(); await pangeaController.myAnalytics.initialize(); pangeaController.afterSyncAndFirstLoginInitialization(context); diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 11be0e097..b9b388da9 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -187,12 +187,7 @@ class ChatListViewBody extends StatelessWidget { ], ), ), - // #Pangea - // Only show loading screen if room list is empty - // because it is still loading - // if (client.prevBatch == null) - if (rooms.isEmpty && client.prevBatch == null) - // Pangea# + if (client.prevBatch == null) SliverList( delegate: SliverChildBuilderDelegate( (context, i) => Opacity( @@ -250,10 +245,7 @@ class ChatListViewBody extends StatelessWidget { childCount: dummyChatCount, ), ), - // #Pangea - // if (client.prevBatch != null) - if (rooms.isNotEmpty) - // Pangea# + if (client.prevBatch != null) SliverList.builder( itemCount: rooms.length, itemBuilder: (BuildContext context, int i) {