fix localContent being outdated for edits
This commit is contained in:
parent
684d6bad82
commit
36917bbea5
2 changed files with 43 additions and 26 deletions
|
|
@ -42,9 +42,25 @@ class const Composer(
|
||||||
final relatedEvent = this.relatedEvent == null
|
final relatedEvent = this.relatedEvent == null
|
||||||
? null
|
? null
|
||||||
: ref.watch(
|
: ref.watch(
|
||||||
RoomsController.provider.select(
|
RoomsController.provider.select((rooms) {
|
||||||
(rooms) => rooms[roomId]?.events[this.relatedEvent!],
|
final event = rooms[roomId]?.events[this.relatedEvent!];
|
||||||
),
|
if (event == null) return null;
|
||||||
|
|
||||||
|
final edited = event.lastEditRowId == 0
|
||||||
|
? null
|
||||||
|
: ref.watch(
|
||||||
|
RoomsController.provider.select(
|
||||||
|
(value) => value[roomId]?.events[event.lastEditRowId],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return edited == null
|
||||||
|
? event
|
||||||
|
: event.copyWith(
|
||||||
|
content: edited.content,
|
||||||
|
localContent: edited.localContent,
|
||||||
|
);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (relationType == .edit && controller.value.text.isEmpty) {
|
if (relationType == .edit && controller.value.text.isEmpty) {
|
||||||
|
|
|
||||||
|
|
@ -48,33 +48,34 @@ class const EventRenderer(
|
||||||
final focusNode = useFocusNode();
|
final focusNode = useFocusNode();
|
||||||
useListenable(focusNode);
|
useListenable(focusNode);
|
||||||
|
|
||||||
final (initialEvent, previousEvent) = ref.watch(
|
final (event, previousEvent) = ref.watch(
|
||||||
RoomsController.provider.select(
|
RoomsController.provider.select((rooms) {
|
||||||
(value) => (
|
final event = rooms[roomId]?.events[eventRowId];
|
||||||
value[roomId]?.events[eventRowId],
|
if (event == null) return (null, null);
|
||||||
|
|
||||||
|
final edited = event.lastEditRowId == 0
|
||||||
|
? null
|
||||||
|
: ref.watch(
|
||||||
|
RoomsController.provider.select(
|
||||||
|
(value) => value[roomId]?.events[event.lastEditRowId],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
edited == null
|
||||||
|
? event
|
||||||
|
: event.copyWith(
|
||||||
|
content: edited.content,
|
||||||
|
localContent: edited.localContent,
|
||||||
|
),
|
||||||
previousEventRowId == null
|
previousEventRowId == null
|
||||||
? null
|
? null
|
||||||
: value[roomId]?.events[previousEventRowId!],
|
: rooms[roomId]?.events[previousEventRowId!],
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (initialEvent == null) return SizedBox.shrink();
|
if (event == null) return SizedBox.shrink();
|
||||||
|
|
||||||
final edited = initialEvent.lastEditRowId == 0
|
|
||||||
? null
|
|
||||||
: ref.watch(
|
|
||||||
RoomsController.provider.select(
|
|
||||||
(value) => value[roomId]?.events[initialEvent.lastEditRowId],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final event = edited == null
|
|
||||||
? initialEvent
|
|
||||||
: initialEvent.copyWith(
|
|
||||||
content: edited.content,
|
|
||||||
localContent: edited.localContent,
|
|
||||||
);
|
|
||||||
|
|
||||||
final isGrouped =
|
final isGrouped =
|
||||||
previousEvent?.content is MessageContent &&
|
previousEvent?.content is MessageContent &&
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue