refactor: Not nullable room in ChatPage

This commit is contained in:
Krille 2023-03-25 15:06:12 +01:00
commit e690f1e14c
10 changed files with 102 additions and 95 deletions

View file

@ -46,14 +46,14 @@ class PinnedEvents extends StatelessWidget {
@override
Widget build(BuildContext context) {
final pinnedEventIds = controller.room!.pinnedEventIds;
final pinnedEventIds = controller.room.pinnedEventIds;
if (pinnedEventIds.isEmpty) {
return const SizedBox.shrink();
}
final completers = pinnedEventIds.map<Completer<Event?>>((e) {
final completer = Completer<Event?>();
controller.room!
controller.room
.getEventById(e)
.then((value) => completer.complete(value));
return completer;
@ -86,11 +86,10 @@ class PinnedEvents extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurfaceVariant,
icon: const Icon(Icons.push_pin),
tooltip: L10n.of(context)!.unpin,
onPressed: controller.room
?.canSendEvent(EventTypes.RoomPinnedEvents) ??
false
? () => controller.unpinEvent(event.eventId)
: null,
onPressed:
controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
? () => controller.unpinEvent(event.eventId)
: null,
),
Expanded(
child: Padding(