chore: Follow up pinned events allow unpin via appbar button

This commit is contained in:
Christian Pauly 2022-02-16 12:11:25 +01:00 committed by Krille Fear
parent e023d52bef
commit edb3adf208

View File

@ -883,13 +883,21 @@ class ChatController extends State<Chat> {
}
void pinEvent() {
final room = this.room;
if (room == null) return;
final pinnedEventIds = room.pinnedEventIds;
final selectedEventIds = selectedEvents.map((e) => e.eventId).toSet();
final pin = selectedEventIds.any((e) => !pinnedEventIds.contains(e));
showFutureLoadingDialog(
context: context,
future: () => room!.setPinnedEvents(
<String>{
...room!.pinnedEventIds,
future: () => room.setPinnedEvents(
pin
? <String>{
...pinnedEventIds,
...selectedEvents.map((e) => e.eventId),
}.toList(),
}.toList()
: pinnedEventIds
..removeWhere(selectedEventIds.contains),
),
);
}