don't have unk langCode to analytics room, fallback to user's target language

This commit is contained in:
ggurdin 2024-06-24 15:29:26 -04:00
parent 05a6957141
commit 6a18967baf
2 changed files with 6 additions and 9 deletions

View file

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:developer';
import 'package:fluffychat/pangea/constants/language_keys.dart';
import 'package:fluffychat/pangea/constants/local.key.dart';
import 'package:fluffychat/pangea/constants/pangea_event_types.dart';
import 'package:fluffychat/pangea/controllers/base_controller.dart';
@ -256,9 +257,12 @@ class MyAnalyticsController extends BaseController {
// sort those messages by their langCode
// langCode is hopefully based on the original sent rep, but if that
// is null, it will be based on the user's current l2
// is null or unk, it will be based on the user's current l2
for (final msg in recentMsgs) {
final String msgLangCode = msg.originalSent?.langCode ?? userL2;
final String msgLangCode = (msg.originalSent?.langCode != null &&
msg.originalSent?.langCode != LanguageKeys.unknownLanguage)
? msg.originalSent!.langCode
: userL2;
langCodeToMsgs[msgLangCode] ??= [];
langCodeToMsgs[msgLangCode]!.add(msg);
}

View file

@ -2,7 +2,6 @@ import 'dart:developer';
import 'dart:ui';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pangea/constants/language_keys.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart';
import 'package:fluffychat/pangea/models/representation_content_model.dart';
@ -191,12 +190,6 @@ class PangeaRichTextState extends State<PangeaRichText> {
: richText;
}
bool get areLanguagesSet =>
userL2LangCode != null && userL2LangCode != LanguageKeys.unknownLanguage;
String? get userL2LangCode =>
pangeaController.languageController.activeL2Code();
Future<void> onIgnore() async {
debugPrint("PTODO implement onIgnore");
}