chore: when choices array goes off screen, stop playing TTS (#1945)

This commit is contained in:
ggurdin 2025-02-26 13:31:22 -05:00 committed by GitHub
parent 2140bbf0bb
commit 907ad15f79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 2 deletions

View file

@ -338,6 +338,7 @@ class Choreographer {
_textController.selection =
TextSelection.collapsed(offset: _textController.text.length);
giveInputFocus();
tts.stop();
}
Future<void> onReplacementSelect({

View file

@ -16,6 +16,7 @@ import 'package:fluffychat/pangea/choreographer/utils/match_copy.dart';
import 'package:fluffychat/pangea/choreographer/widgets/igc/card_error_widget.dart';
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
import 'package:fluffychat/pangea/toolbar/controllers/tts_controller.dart';
import '../../../../widgets/matrix.dart';
import '../../../bot/widgets/bot_face_svg.dart';
import '../../../common/controllers/pangea_controller.dart';
@ -63,6 +64,14 @@ class SpanCardState extends State<SpanCard> {
fetchSelected();
}
@override
void dispose() {
tts.stop();
super.dispose();
}
TtsController get tts => widget.scm.choreographer.tts;
//get selected choice
SpanChoice? get selectedChoice {
if (selectedChoiceIndex == null) return null;
@ -308,7 +317,7 @@ class WordMatchContent extends StatelessWidget {
uniqueKeyForLayerLink: (int index) =>
"wordMatch$index",
selectedChoiceIndex: controller.selectedChoiceIndex,
tts: controller.widget.scm.choreographer.tts,
tts: controller.tts,
),
const SizedBox(height: 12),
PromptAndFeedback(controller: controller),

View file

@ -89,7 +89,7 @@ class AlternativeTranslations extends StatelessWidget {
},
uniqueKeyForLayerLink: (int index) => "altTranslation$index",
selectedChoiceIndex: null,
tts: controller.choreographer.tts,
tts: null,
);
}
}

View file

@ -275,6 +275,7 @@ class PracticeActivityCardState extends State<PracticeActivityCard> {
// wait for savor the joy before popping from the activity queue
// to keep the completed activity on screen for a moment
widget.overlayController.onActivityFinish(currentActivity!.activityType);
widget.overlayController.widget.chatController.choreographer.tts.stop();
} catch (e, s) {
_onError();
debugger(when: kDebugMode);