diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 0fba05c03..f5d2234de 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -519,7 +519,7 @@ class ChatController extends State void _pangeaInit() { choreographer = Choreographer(inputFocus); - choreographer.timesClosedIT.addListener(_onCloseIT); + choreographer.timesDismissedIT.addListener(_onCloseIT); final updater = Matrix.of(context).analyticsDataService.updateDispatcher; _levelSubscription = updater.levelUpdateStream.stream.listen(_onLevelUp); @@ -791,7 +791,7 @@ class ChatController extends State _botAudioSubscription?.cancel(); _constructsSubscription?.cancel(); _router.routeInformationProvider.removeListener(_onRouteChanged); - choreographer.timesClosedIT.removeListener(_onCloseIT); + choreographer.timesDismissedIT.removeListener(_onCloseIT); scrollController.dispose(); inputFocus.dispose(); depressMessageButton.dispose(); @@ -2265,7 +2265,7 @@ class ChatController extends State } void _onCloseIT() { - if (choreographer.timesClosedIT.value >= 3) { + if (choreographer.timesDismissedIT.value >= 3) { showDisableLanguageToolsPopup(); } } diff --git a/lib/pangea/choreographer/choreographer.dart b/lib/pangea/choreographer/choreographer.dart index 25de5f6f2..52348dea6 100644 --- a/lib/pangea/choreographer/choreographer.dart +++ b/lib/pangea/choreographer/choreographer.dart @@ -38,7 +38,7 @@ class Choreographer extends ChangeNotifier { ChoreoRecordModel? _choreoRecord; final ValueNotifier _isFetching = ValueNotifier(false); - final ValueNotifier _timesClosedIT = ValueNotifier(0); + final ValueNotifier _timesDismissedIT = ValueNotifier(0); int _timesClicked = 0; Timer? _debounceTimer; @@ -58,7 +58,7 @@ class Choreographer extends ChangeNotifier { int get timesClicked => _timesClicked; ValueNotifier get isFetching => _isFetching; - ValueNotifier get timesClosedIT => _timesClosedIT; + ValueNotifier get timesDismissedIT => _timesDismissedIT; ChoreoModeEnum get choreoMode => _choreoMode; String get currentText => textController.text; @@ -111,6 +111,7 @@ class Choreographer extends ChangeNotifier { _choreoRecord = null; itController.closeIT(); itController.clearSourceText(); + itController.clearDissmissed(); igcController.clear(); _resetDebounceTimer(); _setChoreoMode(ChoreoModeEnum.igc); @@ -134,7 +135,7 @@ class Choreographer extends ChangeNotifier { errorService.dispose(); textController.dispose(); _isFetching.dispose(); - _timesClosedIT.dispose(); + _timesDismissedIT.dispose(); TtsController.stop(); super.dispose(); @@ -149,7 +150,7 @@ class Choreographer extends ChangeNotifier { // if user is doing IT, call closeIT here to // ensure source text is replaced when needed if (itController.open.value && _timesClicked > 1) { - itController.closeIT(); + itController.closeIT(dismiss: true); } } } @@ -340,7 +341,10 @@ class Choreographer extends ChangeNotifier { ); } - _timesClosedIT.value = _timesClosedIT.value + 1; + debugPrint("DISMISSED: ${itController.dismissed}"); + if (itController.dismissed) { + _timesDismissedIT.value = _timesDismissedIT.value + 1; + } _setChoreoMode(ChoreoModeEnum.igc); errorService.resetError(); } diff --git a/lib/pangea/choreographer/it/it_bar.dart b/lib/pangea/choreographer/it/it_bar.dart index d82a8b37b..db088a019 100644 --- a/lib/pangea/choreographer/it/it_bar.dart +++ b/lib/pangea/choreographer/it/it_bar.dart @@ -195,7 +195,8 @@ class ITBarState extends State with SingleTickerProviderStateMixin { spacing: 12.0, children: [ _ITBarHeader( - onClose: widget.choreographer.itController.closeIT, + onClose: () => + widget.choreographer.itController.closeIT(dismiss: true), setEditing: widget.choreographer.itController.setEditingSourceText, editing: widget.choreographer.itController.editing, diff --git a/lib/pangea/choreographer/it/it_controller.dart b/lib/pangea/choreographer/it/it_controller.dart index fef1bb239..a90c20c00 100644 --- a/lib/pangea/choreographer/it/it_controller.dart +++ b/lib/pangea/choreographer/it/it_controller.dart @@ -35,6 +35,7 @@ class ITController { StreamController.broadcast(); bool _continuing = false; + bool dismissed = false; ITRequestModel _request(String textInput) { assert(_sourceText.value != null); @@ -61,6 +62,10 @@ class ITController { _sourceText.value = null; } + void clearDissmissed() { + dismissed = false; + } + void dispose() { acceptedContinuanceStream.close(); _open.dispose(); @@ -75,10 +80,14 @@ class ITController { _continueIT(); } - void closeIT() { + void closeIT({bool dismiss = false}) { MatrixState.pAnyState.closeOverlay("it_feedback_card"); setEditingSourceText(false); + if (dismiss) { + dismissed = true; + } + _open.value = false; _queue.clear(); _currentITStep.value = null;