From f03d8d7f52152f3b24897d8d48d0019a68d585e6 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Wed, 29 Nov 2023 09:38:21 -0800 Subject: [PATCH] Add filter that takes care of mastodon posts with link preview having duplicate images --- lib/controls/search_result_status_control.dart | 8 ++++++++ lib/controls/timeline/flattened_tree_entry_control.dart | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/controls/search_result_status_control.dart b/lib/controls/search_result_status_control.dart index 6540f86..6ae90be 100644 --- a/lib/controls/search_result_status_control.dart +++ b/lib/controls/search_result_status_control.dart @@ -127,6 +127,14 @@ class _SearchResultStatusControlState extends State { if (items.isEmpty) { return const SizedBox(); } + + // A Link Preview with only one media attachment will have a duplicate image + // even though it points to different resources server side. So we don't + // want to render it twice. + if (widget.status.linkPreviewData != null && items.length == 1) { + return const SizedBox(); + } + return SizedBox( height: 250.0, child: ListView.separated( diff --git a/lib/controls/timeline/flattened_tree_entry_control.dart b/lib/controls/timeline/flattened_tree_entry_control.dart index 19c9e5f..1baf45c 100644 --- a/lib/controls/timeline/flattened_tree_entry_control.dart +++ b/lib/controls/timeline/flattened_tree_entry_control.dart @@ -228,6 +228,14 @@ class _StatusControlState extends State { if (items.isEmpty) { return const SizedBox(); } + + // A Link Preview with only one media attachment will have a duplicate image + // even though it points to different resources server side. So we don't + // want to render it twice. + if (entry.linkPreviewData != null && items.length == 1) { + return const SizedBox(); + } + return SizedBox( height: ResponsiveSizesCalculator(context).maxThumbnailHeight, child: ListView.separated(