|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
|
|
|
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
|
|
|
import 'package:fluffychat/pangea/constants/pangea_message_types.dart';
|
|
|
|
import 'package:fluffychat/pangea/constants/pangea_message_types.dart';
|
|
|
|
@ -6,6 +8,7 @@ import 'package:fluffychat/pangea/models/choreo_record.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/message_data_models.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/message_data_models.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/pangea_representation_event.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/pangea_representation_event.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,10 +87,7 @@ class PangeaMessageEvent {
|
|
|
|
|
|
|
|
|
|
|
|
_representations = [];
|
|
|
|
_representations = [];
|
|
|
|
|
|
|
|
|
|
|
|
final bool latestHasTokens =
|
|
|
|
if (_latestEdit.content[ModelKey.originalSent] != null) {
|
|
|
|
_latestEdit.content[ModelKey.tokensSent] != null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_latestEdit.content[ModelKey.originalSent] != null && latestHasTokens) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
_representations!.add(
|
|
|
|
_representations!.add(
|
|
|
|
RepresentationEvent(
|
|
|
|
RepresentationEvent(
|
|
|
|
@ -95,9 +95,12 @@ class PangeaMessageEvent {
|
|
|
|
_latestEdit.content[ModelKey.originalSent]
|
|
|
|
_latestEdit.content[ModelKey.originalSent]
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
tokens: PangeaMessageTokens.fromJson(
|
|
|
|
tokens: _latestEdit.content[ModelKey.tokensSent] != null
|
|
|
|
_latestEdit.content[ModelKey.tokensSent] as Map<String, dynamic>,
|
|
|
|
? PangeaMessageTokens.fromJson(
|
|
|
|
),
|
|
|
|
_latestEdit.content[ModelKey.tokensSent]
|
|
|
|
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: null,
|
|
|
|
choreo: _latestEdit.content[ModelKey.choreoRecord] != null
|
|
|
|
choreo: _latestEdit.content[ModelKey.choreoRecord] != null
|
|
|
|
? ChoreoRecord.fromJson(
|
|
|
|
? ChoreoRecord.fromJson(
|
|
|
|
_latestEdit.content[ModelKey.choreoRecord]
|
|
|
|
_latestEdit.content[ModelKey.choreoRecord]
|
|
|
|
@ -109,26 +112,37 @@ class PangeaMessageEvent {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} catch (err, s) {
|
|
|
|
} catch (err, s) {
|
|
|
|
ErrorHandler.logError(
|
|
|
|
ErrorHandler.logError(
|
|
|
|
|
|
|
|
m: "error parsing originalSent",
|
|
|
|
e: err,
|
|
|
|
e: err,
|
|
|
|
s: s,
|
|
|
|
s: s,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_latestEdit.content[ModelKey.originalWritten] != null &&
|
|
|
|
if (_latestEdit.content[ModelKey.originalWritten] != null) {
|
|
|
|
latestHasTokens) {
|
|
|
|
try {
|
|
|
|
_representations!.add(
|
|
|
|
_representations!.add(
|
|
|
|
RepresentationEvent(
|
|
|
|
RepresentationEvent(
|
|
|
|
content: PangeaRepresentation.fromJson(
|
|
|
|
content: PangeaRepresentation.fromJson(
|
|
|
|
_latestEdit.content[ModelKey.originalWritten]
|
|
|
|
_latestEdit.content[ModelKey.originalWritten]
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
tokens: PangeaMessageTokens.fromJson(
|
|
|
|
tokens: _latestEdit.content[ModelKey.tokensWritten] != null
|
|
|
|
_latestEdit.content[ModelKey.tokensWritten] as Map<String, dynamic>,
|
|
|
|
? PangeaMessageTokens.fromJson(
|
|
|
|
|
|
|
|
_latestEdit.content[ModelKey.tokensWritten]
|
|
|
|
|
|
|
|
as Map<String, dynamic>,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
timeline: timeline,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
timeline: timeline,
|
|
|
|
);
|
|
|
|
),
|
|
|
|
} catch (err, s) {
|
|
|
|
);
|
|
|
|
ErrorHandler.logError(
|
|
|
|
|
|
|
|
m: "error parsing originalWritten",
|
|
|
|
|
|
|
|
e: err,
|
|
|
|
|
|
|
|
s: s,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_representations!.addAll(
|
|
|
|
_representations!.addAll(
|
|
|
|
@ -174,6 +188,11 @@ class PangeaMessageEvent {
|
|
|
|
|
|
|
|
|
|
|
|
RepresentationEvent? rep = representationByLanguage(langCode);
|
|
|
|
RepresentationEvent? rep = representationByLanguage(langCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if event is less than 1 minute old, then print new event
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
|
|
|
|
debugger(when: kDebugMode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while ((isNew || eventId.contains("web")) && tries < 20) {
|
|
|
|
while ((isNew || eventId.contains("web")) && tries < 20) {
|
|
|
|
if (rep != null) return rep;
|
|
|
|
if (rep != null) return rep;
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
|