add thread support

Fixes #129
This commit is contained in:
Henry Hiles 2026-11-05 19:14:46 -05:00
commit 7f7bdbf525
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -29,6 +29,8 @@ class const Event({
final String? sendError,
final IMap<String, int> reactions = const .empty(),
@JsonKey(name: "last_edit_rowid") final int lastEditRowId = 0,
final int threadCount = 0,
@JsonKey(name: "thread_latest_rowid") final int threadLatestRowId = 0,
final UnreadType? unreadType,
final Profile? pmp,
required final Content content,
@ -36,6 +38,8 @@ class const Event({
}) with _$Event {
Map<String, Object?> toJson() => _$EventToJson(this);
String? get threadRoot => relationType == "m.thread" ? relatesTo : null;
static String typeJsonFromJson(Map<dynamic, dynamic> json, _) =>
json["decrypted_type"] ?? json["type"];
@ -47,7 +51,15 @@ class const Event({
static String? replyToFromJson(Map<dynamic, dynamic> json) {
try {
return json["m.relates_to"]?["m.in_reply_to"]?["event_id"];
final relatesTo = json["m.relates_to"];
// Thread fallbacks are only for clients without thread support
if (relatesTo?["rel_type"] == "m.thread" &&
relatesTo?["is_falling_back"] == true) {
return null;
}
return relatesTo?["m.in_reply_to"]?["event_id"];
} catch (_) {
return null;
}