diff --git a/lib/pangea/choreographer/controllers/igc_controller.dart b/lib/pangea/choreographer/controllers/igc_controller.dart index b0c8dd462..d5fd0de95 100644 --- a/lib/pangea/choreographer/controllers/igc_controller.dart +++ b/lib/pangea/choreographer/controllers/igc_controller.dart @@ -55,6 +55,9 @@ class IgcController { try { if (choreographer.currentText.isEmpty) return clear(); + // the error spans are going to be reloaded, so clear the cache + _clearCache(); + debugPrint('getIGCTextData called with ${choreographer.currentText}'); debugPrint('getIGCTextData called with tokensOnly = $tokensOnly'); @@ -287,6 +290,7 @@ class IgcController { clear() { igcTextData = null; + _clearCache(); // Not sure why this is here // MatrixState.pAnyState.closeOverlay(); } diff --git a/lib/pangea/repo/span_data_repo.dart b/lib/pangea/repo/span_data_repo.dart index e253bb1d0..f06363fd1 100644 --- a/lib/pangea/repo/span_data_repo.dart +++ b/lib/pangea/repo/span_data_repo.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:collection/collection.dart'; import 'package:fluffychat/pangea/config/environment.dart'; import 'package:fluffychat/pangea/enum/span_choice_type.dart'; import 'package:fluffychat/pangea/enum/span_data_type.dart'; @@ -80,15 +81,39 @@ class SpanDetailsRepoReqAndRes { bool operator ==(Object other) { if (identical(this, other)) return true; if (other is! SpanDetailsRepoReqAndRes) return false; - - return toJson().toString() == other.toJson().toString(); + if (other.userL1 != userL1) return false; + if (other.userL2 != userL2) return false; + if (other.enableIT != enableIT) return false; + if (other.enableIGC != enableIGC) return false; + if (other.span.choices + ?.firstWhere( + (choice) => choice.type == SpanChoiceType.bestCorrection, + ) + .value != + span.choices + ?.firstWhere( + (choice) => choice.type == SpanChoiceType.bestCorrection, + ) + .value) return false; + return true; } /// Overrides the hashCode getter to generate a hash code for the [SpanDetailsRepoReqAndRes] object. /// Used as keys in response cache in igc_controller. @override int get hashCode { - return toJson().toString().hashCode; + return Object.hashAll([ + userL1.hashCode, + userL2.hashCode, + enableIT.hashCode, + enableIGC.hashCode, + span.choices + ?.firstWhereOrNull( + (choice) => choice.type == SpanChoiceType.bestCorrection, + ) + ?.value + .hashCode, + ]); } } diff --git a/lib/pangea/utils/bot_style.dart b/lib/pangea/utils/bot_style.dart index 3791c205e..1a3a2f8fb 100644 --- a/lib/pangea/utils/bot_style.dart +++ b/lib/pangea/utils/bot_style.dart @@ -19,11 +19,7 @@ class BotStyle { AppConfig.fontSizeFactor * (big == true ? 1.2 : 1), fontStyle: italics ? FontStyle.italic : null, - color: setColor - ? Theme.of(context).brightness == Brightness.dark - ? AppConfig.primaryColorLight - : AppConfig.primaryColor - : null, + color: setColor ? Theme.of(context).colorScheme.primary : null, inherit: true, );