Merge pull request #5549 from pangeachat/5548-edit-section-of-input-bar-not-going-away-automatically

fix: update UI on reply / edit event update
This commit is contained in:
ggurdin 2026-02-02 13:30:24 -05:00 committed by GitHub
commit a41d96dff3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 81 additions and 52 deletions

View file

@ -253,9 +253,14 @@ class ChatController extends State<ChatPageWithRoom>
final Set<String> unfolded = {};
Event? replyEvent;
// #Pangea
// Event? replyEvent;
Event? editEvent;
// Event? editEvent;
ValueNotifier<Event?> replyEvent = ValueNotifier(null);
ValueNotifier<Event?> editEvent = ValueNotifier(null);
// Pangea#
bool _scrolledUp = false;
@ -898,10 +903,10 @@ class ChatController extends State<ChatPageWithRoom>
// Also, adding PangeaMessageData
Future<void> send() async {
final message = sendController.text;
final edit = editEvent;
final reply = replyEvent;
editEvent = null;
replyEvent = null;
final edit = editEvent.value;
final reply = replyEvent.value;
editEvent.value = null;
replyEvent.value = null;
pendingText = '';
final tempEventId = await sendFakeMessage(edit, reply);
@ -956,7 +961,7 @@ class ChatController extends State<ChatPageWithRoom>
sendController.setSystemText("", EditTypeEnum.other);
}
final previousEdit = editEvent;
final previousEdit = edit;
if (showEmojiPicker) {
hideEmojiPicker();
}
@ -1011,8 +1016,8 @@ class ChatController extends State<ChatPageWithRoom>
data: {
'roomId': roomId,
'text': message,
'inReplyTo': replyEvent?.eventId,
'editEventId': editEvent?.eventId,
'inReplyTo': reply?.eventId,
'editEventId': edit?.eventId,
},
);
return;
@ -1032,8 +1037,8 @@ class ChatController extends State<ChatPageWithRoom>
data: {
'roomId': roomId,
'text': message,
'inReplyTo': replyEvent?.eventId,
'editEventId': editEvent?.eventId,
'inReplyTo': reply?.eventId,
'editEventId': edit?.eventId,
},
);
});
@ -1161,8 +1166,8 @@ class ChatController extends State<ChatPageWithRoom>
);
// #Pangea
final reply = replyEvent;
replyEvent = null;
final reply = replyEvent.value;
replyEvent.value = null;
// Pangea#
await room
@ -1530,7 +1535,7 @@ class ChatController extends State<ChatPageWithRoom>
void replyAction({Event? replyTo}) {
// #Pangea
replyEvent = replyTo ?? selectedEvents.first;
replyEvent.value = replyTo ?? selectedEvents.first;
clearSelectedEvents();
// setState(() {
// replyEvent = replyTo ?? selectedEvents.first;
@ -1688,9 +1693,9 @@ class ChatController extends State<ChatPageWithRoom>
// selectedEvents.clear();
// });
pendingText = sendController.text;
editEvent = selectedEvents.first;
editEvent.value = selectedEvents.first;
sendController.text =
editEvent!.getDisplayEvent(timeline!).calcLocalizedBodyFallback(
editEvent.value!.getDisplayEvent(timeline!).calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)),
withSenderNamePrefix: false,
hideReply: true,
@ -1972,15 +1977,17 @@ class ChatController extends State<ChatPageWithRoom>
}
void cancelReplyEventAction() => setState(() {
if (editEvent != null) {
// #Pangea
// sendController.text = pendingText;
sendController.setSystemText(pendingText, EditTypeEnum.other);
// Pangea#
pendingText = '';
}
replyEvent = null;
editEvent = null;
// #Pangea
// sendController.text = pendingText;
sendController.setSystemText(pendingText, EditTypeEnum.other);
// Pangea#
pendingText = '';
// #Pangea
// replyEvent = null;
// editEvent = null;
replyEvent.value = null;
editEvent.value = null;
// Pangea#
});
// #Pangea
ValueNotifier<bool> depressMessageButton = ValueNotifier(false);

View file

@ -16,35 +16,57 @@ class ReplyDisplay extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AnimatedContainer(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
height: controller.editEvent != null || controller.replyEvent != null
? 56
: 0,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: theme.colorScheme.onInverseSurface,
),
child: Row(
children: <Widget>[
IconButton(
tooltip: L10n.of(context).close,
icon: const Icon(Icons.close),
onPressed: controller.cancelReplyEventAction,
// #Pangea
return ListenableBuilder(
listenable:
Listenable.merge([controller.replyEvent, controller.editEvent]),
builder: (context, __) {
final editEvent = controller.editEvent.value;
final replyEvent = controller.replyEvent.value;
// Pangea#
return AnimatedContainer(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
// #Pangea
// height: controller.editEvent != null || controller.replyEvent != null
height: editEvent != null || replyEvent != null
// Pangea#
? 56
: 0,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: theme.colorScheme.onInverseSurface,
),
Expanded(
child: controller.replyEvent != null
? ReplyContent(
controller.replyEvent!,
timeline: controller.timeline!,
)
: _EditContent(
controller.editEvent?.getDisplayEvent(controller.timeline!),
),
child: Row(
children: <Widget>[
IconButton(
tooltip: L10n.of(context).close,
icon: const Icon(Icons.close),
onPressed: controller.cancelReplyEventAction,
),
Expanded(
// #Pangea
// child: controller.replyEvent != null
child: replyEvent != null
// Pangea#
? ReplyContent(
// #Pangea
// controller.replyEvent,
replyEvent,
// Pangea#
timeline: controller.timeline!,
)
: _EditContent(
// #Pangea
// controller.editEvent?.getDisplayEvent(controller.timeline!),
editEvent?.getDisplayEvent(controller.timeline!),
// Pangea#
),
),
],
),
],
),
);
},
);
}
}