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() { 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( showFutureLoadingDialog(
context: context, context: context,
future: () => room!.setPinnedEvents( future: () => room.setPinnedEvents(
<String>{ pin
...room!.pinnedEventIds, ? <String>{
...selectedEvents.map((e) => e.eventId), ...pinnedEventIds,
}.toList(), ...selectedEvents.map((e) => e.eventId),
}.toList()
: pinnedEventIds
..removeWhere(selectedEventIds.contains),
), ),
); );
} }