Remove flutter chat #26

Manually merged
Henry-Hiles merged 108 commits from remove-flutter-chat into main 2026-05-22 15:26:28 -04:00
Showing only changes of commit e7bcf956e3 - Show all commits

improve legibility of content parsing

Henry Hiles 2026-05-19 22:46:36 -04:00
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -16,6 +16,12 @@ abstract class Event with _$Event {
static String typeJsonFromJson(Map<dynamic, dynamic> json, _) => static String typeJsonFromJson(Map<dynamic, dynamic> json, _) =>
json["decrypted_type"] ?? json["type"]; json["decrypted_type"] ?? json["type"];
static Map<String, dynamic> getContentFromJson(Map<dynamic, dynamic> json) {
final content = json["decrypted"] ?? json["content"];
return content["m.new_content"] ?? content;
}
const factory Event({ const factory Event({
@JsonKey(name: "rowid") required int rowId, @JsonKey(name: "rowid") required int rowId,
@JsonKey(name: "timeline_rowid") required int timelineRowId, @JsonKey(name: "timeline_rowid") required int timelineRowId,
@ -44,14 +50,11 @@ abstract class Event with _$Event {
factory Event.fromJson(Map<String, dynamic> json) => factory Event.fromJson(Map<String, dynamic> json) =>
_$EventFromJson(json).copyWith( _$EventFromJson(json).copyWith(
replyTo: replyTo: getContentFromJson(
((json["decrypted"] ?? json["content"])["m.new_content"] ?? json,
json["decrypted"] ?? )["m.relates_to"]?["m.in_reply_to"]?["event_id"],
json["content"])?["m.relates_to"]?["m.in_reply_to"]?["event_id"],
content: Content.fromEventJson( content: Content.fromEventJson(
(json["decrypted"] ?? json["content"])["m.new_content"] ?? getContentFromJson(json),
json["decrypted"] ??
json["content"],
json["decrypted_type"] ?? json["type"], json["decrypted_type"] ?? json["type"],
), ),
previousContent: json["unsigned"]?["prev_content"] == null previousContent: json["unsigned"]?["prev_content"] == null