Merge branch 'krille/pinned-events-high' into 'main'

fix: Hide pinned events if event is not accessable or loading

See merge request famedly/fluffychat!800
This commit is contained in:
Krille Fear 2022-04-03 06:35:49 +00:00
commit fd248aad53

View File

@ -60,82 +60,68 @@ class PinnedEvents extends StatelessWidget {
? snapshot.data?.last ? snapshot.data?.last
: null; : null;
if (event != null && pinnedEvents != null) { if (event == null || pinnedEvents == null) {
final fontSize = return Container();
AppConfig.messageFontSize * AppConfig.fontSizeFactor; }
return Material(
color: Theme.of(context).appBarTheme.backgroundColor, final fontSize = AppConfig.messageFontSize * AppConfig.fontSizeFactor;
elevation: Theme.of(context).appBarTheme.elevation ?? 10, return Material(
shadowColor: Theme.of(context).appBarTheme.shadowColor, color: Theme.of(context).appBarTheme.backgroundColor,
child: InkWell( elevation: Theme.of(context).appBarTheme.elevation ?? 10,
onTap: () => _displayPinnedEventsDialog( shadowColor: Theme.of(context).appBarTheme.shadowColor,
context, child: InkWell(
pinnedEvents, onTap: () => _displayPinnedEventsDialog(
), context,
child: Row( pinnedEvents,
children: [ ),
IconButton( child: Row(
splashRadius: 20, children: [
iconSize: 20, IconButton(
icon: const Icon(Icons.push_pin), splashRadius: 20,
tooltip: L10n.of(context)!.unpin, iconSize: 20,
onPressed: controller.room icon: const Icon(Icons.push_pin),
?.canSendEvent(EventTypes.RoomPinnedEvents) ?? tooltip: L10n.of(context)!.unpin,
false onPressed: controller.room
? () => controller.unpinEvent(event.eventId) ?.canSendEvent(EventTypes.RoomPinnedEvents) ??
: null, false
), ? () => controller.unpinEvent(event.eventId)
Expanded( : null,
child: Padding( ),
padding: const EdgeInsets.symmetric(horizontal: 4.0), Expanded(
child: LinkText( child: Padding(
text: event.getLocalizedBody( padding: const EdgeInsets.symmetric(horizontal: 4.0),
MatrixLocals(L10n.of(context)!), child: LinkText(
withSenderNamePrefix: true, text: event.getLocalizedBody(
hideReply: true, MatrixLocals(L10n.of(context)!),
), withSenderNamePrefix: true,
maxLines: 2, hideReply: true,
textStyle: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: fontSize,
decoration: event.redacted
? TextDecoration.lineThrough
: null,
),
linkStyle: TextStyle(
color: Theme.of(context)
.textTheme
.bodyText1
?.color
?.withAlpha(150),
fontSize: fontSize,
decoration: TextDecoration.underline,
),
onLinkTap: (url) =>
UrlLauncher(context, url).launchUrl(),
), ),
maxLines: 2,
textStyle: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: fontSize,
decoration: event.redacted
? TextDecoration.lineThrough
: null,
),
linkStyle: TextStyle(
color: Theme.of(context)
.textTheme
.bodyText1
?.color
?.withAlpha(150),
fontSize: fontSize,
decoration: TextDecoration.underline,
),
onLinkTap: (url) =>
UrlLauncher(context, url).launchUrl(),
), ),
), ),
], ),
), ],
), ),
); ),
} else if (snapshot.hasError) { );
Logs().e('Error loading pinned events.', snapshot.error);
return ListTile(
tileColor: Theme.of(context).secondaryHeaderColor,
title: Text(L10n.of(context)!.pinnedEventsError));
} else {
return ListTile(
tileColor: Theme.of(context).secondaryHeaderColor,
title: const Center(
child: SizedBox.square(
dimension: 24,
child: CircularProgressIndicator(),
),
),
);
}
}); });
} }
} }