working edits

This commit is contained in:
Henry Hiles 2026-05-19 21:18:27 -04:00
commit 7761ca73fd
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 20 additions and 9 deletions

View file

@ -62,11 +62,21 @@ class RoomChatController extends AsyncNotifier<IList<Event>> {
}
return room.timeline.reversed
.map(
(timeline) => room.events.firstWhereOrNull(
.map((timeline) {
final foundEvent = room.events.firstWhereOrNull(
(event) => event.rowId == timeline.eventRowId,
),
)
);
final editedEvent = foundEvent?.lastEditRowId == 0
? null
: room.events.firstWhereOrNull(
(event) => event.rowId == foundEvent?.lastEditRowId,
);
return foundEvent?.copyWith(
content: editedEvent?.content ?? foundEvent.content,
);
})
.nonNulls
.toIList();
}

View file

@ -34,7 +34,7 @@ abstract class Event with _$Event {
String? decryptionError,
String? sendError,
@Default(IMap.empty()) IMap<String, int> reactions,
@JsonKey(name: "last_edit_rowid") int? lastEditRowId,
@JsonKey(name: "last_edit_rowid") @Default(0) int lastEditRowId,
@UnreadTypeConverter() UnreadType? unreadType,
@JsonKey(fromJson: Event.pmpFromJson) Profile? pmp,
required Content content,
@ -44,7 +44,9 @@ abstract class Event with _$Event {
factory Event.fromJson(Map<String, dynamic> json) =>
_$EventFromJson(json).copyWith(
content: Content.fromEventJson(
json["decrypted"] ?? json["content"],
(json["decrypted"] ?? json["content"])["m.new_content"] ??
json["decrypted"] ??
json["content"],
json["decrypted_type"] ?? json["type"],
),
previousContent: json["unsigned"]?["prev_content"] == null

View file

@ -75,7 +75,7 @@ class EventRenderer extends ConsumerWidget {
fontStyle: event.content is EmoteMessageContent ? FontStyle.italic : null,
);
final child = event.redactedBy != null
final child = event.redactedBy != null || event.relationType == "m.replace"
? null
: switch (event.content) {
Content(:final parseError?) => SelectableText(
@ -344,8 +344,7 @@ class EventRenderer extends ConsumerWidget {
style: errorStyle,
),
},
if (event.lastEditRowId != null &&
!textOnly)
if (event.lastEditRowId != 0 && !textOnly)
Text(
"(edited)",
style: theme.textTheme.labelSmall,