From 9dfece83ee01bb33eea78f787d3de4b3218eb526 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 10 Oct 2024 12:04:55 -0400 Subject: [PATCH] tweaks for logic for showing message click instructions when the user sees the first message --- lib/pages/chat/chat_event_list.dart | 9 +++++++-- lib/pangea/utils/instructions.dart | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/pages/chat/chat_event_list.dart b/lib/pages/chat/chat_event_list.dart index ac155144d..5e82651ce 100644 --- a/lib/pages/chat/chat_event_list.dart +++ b/lib/pages/chat/chat_event_list.dart @@ -46,11 +46,16 @@ class ChatEventList extends StatelessWidget { // after the chat event list mounts, if the user hasn't yet seen this instruction // card, attach it on top of the first shown message WidgetsBinding.instance.addPostFrameCallback((_) { - if (events.isEmpty) return; + final msgEvents = events + .where( + (event) => event.type == EventTypes.Message, + ) + .toList(); + if (msgEvents.isEmpty) return; controller.pangeaController.instructions.showInstructionsPopup( context, InstructionsEnum.clickMessage, - events[0].eventId, + msgEvents[0].eventId, true, ); }); diff --git a/lib/pangea/utils/instructions.dart b/lib/pangea/utils/instructions.dart index ca76b0629..9011f14ed 100644 --- a/lib/pangea/utils/instructions.dart +++ b/lib/pangea/utils/instructions.dart @@ -69,6 +69,12 @@ class InstructionsController { String transformTargetKey, [ bool showToggle = true, ]) async { + final bool userLangsSet = + await _pangeaController.userController.areUserLanguagesSet; + if (!userLangsSet) { + return; + } + if (_instructionsShown[key.toString()] ?? false) { return; } @@ -85,12 +91,6 @@ class InstructionsController { return; } - final bool userLangsSet = - await _pangeaController.userController.areUserLanguagesSet; - if (!userLangsSet) { - return; - } - final botStyle = BotStyle.text(context); Future.delayed( const Duration(seconds: 1),