From d12108411f9b315ab283fcd5a643959605c7e055 Mon Sep 17 00:00:00 2001 From: shannon Date: Mon, 6 Jan 2025 15:36:44 -0500 Subject: [PATCH] Definitely remove duplicates before setting new records Contributes to IOS-351 --- .../MastodonCore/DataController/FeedDataController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MastodonSDK/Sources/MastodonCore/DataController/FeedDataController.swift b/MastodonSDK/Sources/MastodonCore/DataController/FeedDataController.swift index 8322de8c6..a791e649f 100644 --- a/MastodonSDK/Sources/MastodonCore/DataController/FeedDataController.swift +++ b/MastodonSDK/Sources/MastodonCore/DataController/FeedDataController.swift @@ -34,12 +34,14 @@ final public class FeedDataController { public func setRecordsAfterFiltering(_ newRecords: [MastodonFeed]) async { guard let filterBox = StatusFilterService.shared.activeFilterBox else { self.records = newRecords; return } - self.records = await self.filter(newRecords, forFeed: kind, with: filterBox) + let filtered = await self.filter(newRecords, forFeed: kind, with: filterBox) + self.records = filtered.removingDuplicates() } public func appendRecordsAfterFiltering(_ additionalRecords: [MastodonFeed]) async { guard let filterBox = StatusFilterService.shared.activeFilterBox else { self.records += additionalRecords; return } - self.records += await self.filter(additionalRecords, forFeed: kind, with: filterBox) + let newRecords = await self.filter(additionalRecords, forFeed: kind, with: filterBox) + self.records = (self.records + newRecords).removingDuplicates() } public func loadInitial(kind: MastodonFeed.Kind) {