Code deduplication

This commit is contained in:
Inex Code 2020-10-06 18:53:15 +00:00
parent de41700741
commit 84a4a2c0c4

View file

@ -343,17 +343,9 @@ class _ChatState extends State<_Chat> {
setState(() => selectedEvents.clear()); setState(() => selectedEvents.clear());
} }
void replyAction() { void replyAction({Event replyTo}) {
setState(() { setState(() {
replyEvent = selectedEvents.first; replyEvent = replyTo ?? selectedEvents.first;
selectedEvents.clear();
});
inputFocus.requestFocus();
}
void replyBySwipeAction(Event replyTo) {
setState(() {
replyEvent = replyTo;
selectedEvents.clear(); selectedEvents.clear();
}); });
inputFocus.requestFocus(); inputFocus.requestFocus();
@ -696,8 +688,8 @@ class _ChatState extends State<_Chat> {
), ),
direction: SwipeDirection.startToEnd, direction: SwipeDirection.startToEnd,
onSwiped: (direction) { onSwiped: (direction) {
replyBySwipeAction( replyAction(
filteredEvents[i - 1]); replyTo: filteredEvents[i - 1]);
}, },
child: Message(filteredEvents[i - 1], child: Message(filteredEvents[i - 1],
onAvatarTab: (Event event) { onAvatarTab: (Event event) {