refactor: Remove unnecessary FutureBuilder

This commit is contained in:
Krille 2024-05-15 08:20:43 +02:00
commit 8a64bdd82d
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
5 changed files with 76 additions and 129 deletions

View file

@ -63,33 +63,24 @@ class PinnedEvents extends StatelessWidget {
future: controller.room.getEventById(pinnedEventIds.last),
builder: (context, snapshot) {
final event = snapshot.data;
return FutureBuilder<String>(
future: event?.calcLocalizedBody(
MatrixLocals(L10n.of(context)!),
withSenderNamePrefix: true,
hideReply: true,
),
builder: (context, snapshot) => ChatAppBarListTile(
title: snapshot.data ??
event?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
withSenderNamePrefix: true,
hideReply: true,
) ??
L10n.of(context)!.loadingPleaseWait,
leading: IconButton(
splashRadius: 20,
iconSize: 20,
color: Theme.of(context).colorScheme.onSurfaceVariant,
icon: const Icon(Icons.push_pin),
tooltip: L10n.of(context)!.unpin,
onPressed:
controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
? () => controller.unpinEvent(event!.eventId)
: null,
),
onTap: () => _displayPinnedEventsDialog(context),
return ChatAppBarListTile(
title: event?.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
withSenderNamePrefix: true,
hideReply: true,
) ??
L10n.of(context)!.loadingPleaseWait,
leading: IconButton(
splashRadius: 20,
iconSize: 20,
color: Theme.of(context).colorScheme.onSurfaceVariant,
icon: const Icon(Icons.push_pin),
tooltip: L10n.of(context)!.unpin,
onPressed: controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
? () => controller.unpinEvent(event!.eventId)
: null,
),
onTap: () => _displayPinnedEventsDialog(context),
);
},
);