Skip to content

Commit

Permalink
only show preview if we should actually get one
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz committed Jun 5, 2024
1 parent d9d8209 commit 45bfd58
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>
late DateTime sentTime;

UrlPreviewComponent? previewComponent;
bool hasLinks = false;
bool doUrlPreview = false;

int index = 0;

Expand Down Expand Up @@ -93,7 +93,7 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>
? TimelineEventViewReactions(
key: reactionsKey, timeline: widget.timeline, initialIndex: index)
: null,
urlPreviews: previewComponent != null && hasLinks
urlPreviews: previewComponent != null && doUrlPreview
? TimelineEventViewUrlPreviews(
initialIndex: index,
timeline: widget.timeline,
Expand Down Expand Up @@ -146,7 +146,10 @@ class _TimelineEventViewMessageState extends State<TimelineEventViewMessage>

sentTime = event.originServerTs;

hasLinks = event.links?.isNotEmpty == true;
doUrlPreview =
previewComponent?.shouldGetPreviewData(widget.timeline.room, event) ==
true &&
event.links?.isNotEmpty == true;
}

String timestampToString(DateTime time) {
Expand Down

0 comments on commit 45bfd58

Please sign in to comment.