From aa56fa98136d35b656a53c78c67c73f29dc70a19 Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:31:14 +0930 Subject: [PATCH] Update timeline_event_view_url_previews.dart --- .../timeline_event_view_url_previews.dart | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/commet/lib/ui/molecules/timeline_events/events/timeline_event_view_url_previews.dart b/commet/lib/ui/molecules/timeline_events/events/timeline_event_view_url_previews.dart index c1f526d9..8e48395d 100644 --- a/commet/lib/ui/molecules/timeline_events/events/timeline_event_view_url_previews.dart +++ b/commet/lib/ui/molecules/timeline_events/events/timeline_event_view_url_previews.dart @@ -26,6 +26,8 @@ class _TimelineEventViewUrlPreviewsState extends State implements TimelineEventViewWidget { UrlPreviewData? data; + bool loading = false; + GlobalKey key = GlobalKey(); @override @@ -33,13 +35,15 @@ class _TimelineEventViewUrlPreviewsState BenchmarkValues.numTimelineUrlPreviewBuilt += 1; return Padding( padding: const EdgeInsets.fromLTRB(0, 2, 40, 2), - child: UrlPreviewWidget( - key: key, - data, - onTap: () { - LinkUtils.open(data!.uri); - }, - ), + child: (loading || data != null) + ? UrlPreviewWidget( + key: key, + data, + onTap: () { + LinkUtils.open(data!.uri); + }, + ) + : Container(), ); } @@ -65,6 +69,9 @@ class _TimelineEventViewUrlPreviewsState }); if (cachedData == null) { + setState(() { + loading = true; + }); widget.component.getPreview(widget.timeline.room, event).then( (value) async { if (mounted) { @@ -76,6 +83,7 @@ class _TimelineEventViewUrlPreviewsState } setState(() { + loading = false; data = value; key = GlobalKey(); });