File tree 4 files changed +28
-18
lines changed
choreographer/controllers
4 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,11 @@ class IgcController {
113
113
),
114
114
);
115
115
116
- igcTextData! .matches[matchIndex].match = response.span;
116
+ try {
117
+ igcTextData! .matches[matchIndex].match = response.span;
118
+ } catch (err, s) {
119
+ ErrorHandler .logError (e: err, s: s);
120
+ }
117
121
118
122
choreographer.setState ();
119
123
}
Original file line number Diff line number Diff line change 1
- import 'package:fluffychat/pangea/constants/language_keys.dart' ;
2
1
import 'package:fluffychat/pangea/models/speech_to_text_models.dart' ;
3
- import 'package:fluffychat/pangea/utils/error_handler.dart' ;
4
2
import 'package:matrix/matrix.dart' ;
5
- import 'package:sentry_flutter/sentry_flutter.dart' ;
6
3
7
4
/// this class is contained within a [RepresentationEvent]
8
5
/// this event is the child of a [EventTypes.Message]
@@ -56,14 +53,6 @@ class PangeaRepresentation {
56
53
});
57
54
58
55
factory PangeaRepresentation .fromJson (Map <String , dynamic > json) {
59
- if (json[_langCodeKey] == LanguageKeys .unknownLanguage) {
60
- ErrorHandler .logError (
61
- e: Exception ("Language code cannot be 'unk'" ),
62
- s: StackTrace .current,
63
- data: {"rep_content" : json},
64
- level: SentryLevel .warning,
65
- );
66
- }
67
56
return PangeaRepresentation (
68
57
langCode: json[_langCodeKey],
69
58
text: json[_textKey],
Original file line number Diff line number Diff line change 1
1
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart' ;
2
2
import 'package:fluffychat/pangea/models/pangea_match_model.dart' ;
3
+ import 'package:fluffychat/pangea/utils/error_handler.dart' ;
3
4
4
5
class SpanCardModel {
5
6
// IGCTextData igcTextData;
@@ -21,6 +22,18 @@ class SpanCardModel {
21
22
required this .choreographer,
22
23
});
23
24
24
- PangeaMatch ? get pangeaMatch =>
25
- choreographer.igc.igcTextData? .matches[matchIndex];
25
+ PangeaMatch ? get pangeaMatch {
26
+ if (choreographer.igc.igcTextData == null ) return null ;
27
+ if (matchIndex >= choreographer.igc.igcTextData! .matches.length) {
28
+ ErrorHandler .logError (
29
+ m: "matchIndex out of bounds in span card" ,
30
+ data: {
31
+ "matchIndex" : matchIndex,
32
+ "matchesLength" : choreographer.igc.igcTextData? .matches.length,
33
+ },
34
+ );
35
+ return null ;
36
+ }
37
+ return choreographer.igc.igcTextData? .matches[matchIndex];
38
+ }
26
39
}
Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ class SpanCardState extends State<SpanCard> {
58
58
}
59
59
60
60
//get selected choice
61
- SpanChoice ? get selectedChoice => selectedChoiceIndex != null &&
62
- widget.scm.pangeaMatch? .match.choices != null
63
- ? widget.scm.pangeaMatch! .match.choices! [selectedChoiceIndex! ]
64
- : null ;
61
+ SpanChoice ? get selectedChoice {
62
+ if (selectedChoiceIndex == null ||
63
+ widget.scm.pangeaMatch? .match.choices == null ||
64
+ widget.scm.pangeaMatch! .match.choices! .length >= selectedChoiceIndex! ) {
65
+ return null ;
66
+ }
67
+ return widget.scm.pangeaMatch? .match.choices? [selectedChoiceIndex! ];
68
+ }
65
69
66
70
Future <void > getSpanDetails () async {
67
71
try {
You can’t perform that action at this time.
0 commit comments