Remove flutter chat #26
3 changed files with 20 additions and 9 deletions
working edits
commit
7761ca73fd
|
|
@ -62,11 +62,21 @@ class RoomChatController extends AsyncNotifier<IList<Event>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return room.timeline.reversed
|
return room.timeline.reversed
|
||||||
.map(
|
.map((timeline) {
|
||||||
(timeline) => room.events.firstWhereOrNull(
|
final foundEvent = room.events.firstWhereOrNull(
|
||||||
(event) => event.rowId == timeline.eventRowId,
|
(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
|
.nonNulls
|
||||||
.toIList();
|
.toIList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ abstract class Event with _$Event {
|
||||||
String? decryptionError,
|
String? decryptionError,
|
||||||
String? sendError,
|
String? sendError,
|
||||||
@Default(IMap.empty()) IMap<String, int> reactions,
|
@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,
|
@UnreadTypeConverter() UnreadType? unreadType,
|
||||||
@JsonKey(fromJson: Event.pmpFromJson) Profile? pmp,
|
@JsonKey(fromJson: Event.pmpFromJson) Profile? pmp,
|
||||||
required Content content,
|
required Content content,
|
||||||
|
|
@ -44,7 +44,9 @@ 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(
|
||||||
content: Content.fromEventJson(
|
content: Content.fromEventJson(
|
||||||
json["decrypted"] ?? json["content"],
|
(json["decrypted"] ?? json["content"])["m.new_content"] ??
|
||||||
|
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
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class EventRenderer extends ConsumerWidget {
|
||||||
fontStyle: event.content is EmoteMessageContent ? FontStyle.italic : null,
|
fontStyle: event.content is EmoteMessageContent ? FontStyle.italic : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final child = event.redactedBy != null
|
final child = event.redactedBy != null || event.relationType == "m.replace"
|
||||||
? null
|
? null
|
||||||
: switch (event.content) {
|
: switch (event.content) {
|
||||||
Content(:final parseError?) => SelectableText(
|
Content(:final parseError?) => SelectableText(
|
||||||
|
|
@ -344,8 +344,7 @@ class EventRenderer extends ConsumerWidget {
|
||||||
style: errorStyle,
|
style: errorStyle,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
if (event.lastEditRowId != null &&
|
if (event.lastEditRowId != 0 && !textOnly)
|
||||||
!textOnly)
|
|
||||||
Text(
|
Text(
|
||||||
"(edited)",
|
"(edited)",
|
||||||
style: theme.textTheme.labelSmall,
|
style: theme.textTheme.labelSmall,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue