additional error handling in retrieval of practice events

This commit is contained in:
William Jordan-Cooley 2024-10-21 14:40:54 -04:00
parent ac80e6217c
commit 4d2f36890f
2 changed files with 25 additions and 17 deletions

View file

@ -587,18 +587,27 @@ class PangeaMessageEvent {
/// Returns a list of all [PracticeActivityEvent] objects
/// associated with this message event.
List<PracticeActivityEvent> get _practiceActivityEvents {
return _latestEdit
final List<Event> events = _latestEdit
.aggregatedEvents(
timeline,
PangeaEventTypes.pangeaActivity,
)
.map(
(e) => PracticeActivityEvent(
timeline: timeline,
event: e,
),
)
.toList();
final List<PracticeActivityEvent> practiceEvents = [];
for (final event in events) {
try {
practiceEvents.add(
PracticeActivityEvent(
timeline: timeline,
event: event,
),
);
} catch (e, s) {
ErrorHandler.logError(e: e, s: s, data: event.toJson());
}
}
return practiceEvents;
}
/// Returns a boolean value indicating whether there are any
@ -617,7 +626,6 @@ class PangeaMessageEvent {
String langCode, {
bool debug = false,
}) {
// @wcjord - disabled try catch for testing
try {
debugger(when: debug);
final List<PracticeActivityEvent> activities = [];

View file

@ -48,17 +48,17 @@ class WordAudioButtonState extends State<WordAudioButton> {
onPressed: () async {
if (_isPlaying) {
await ttsController.tts.stop();
setState(() {
_isPlaying = false;
});
if (mounted) {
setState(() => _isPlaying = false);
}
} else {
setState(() {
_isPlaying = true;
});
if (mounted) {
setState(() => _isPlaying = true);
}
await ttsController.speak(widget.text);
setState(() {
_isPlaying = false;
});
if (mounted) {
setState(() => _isPlaying = false);
}
}
}, // Disable button if language isn't supported
),