From 3b8686ca4d29036ecefdba5cca2a4128b85dbc72 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Sat, 24 Dec 2022 15:14:52 +0800 Subject: [PATCH 1/2] Adds sorting to widget article arrays Fixes #3783 --- Shared/Widget/WidgetDataEncoder.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index 1b610a8b5..ac4ba2768 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -143,9 +143,9 @@ public final class WidgetDataEncoder { let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, currentTodayCount: SmartFeedsController.shared.todayFeed.unreadCount, currentStarredCount: (try? AccountManager.shared.fetchCountForStarredArticles()) ?? 0, - unreadArticles: unread, - starredArticles: starred, - todayArticles:today, + unreadArticles: unread.sorted(by: { $0.pubDate > $1.pubDate }), + starredArticles: starred.sorted(by: { $0.pubDate > $1.pubDate }), + todayArticles:today.sorted(by: { $0.pubDate > $1.pubDate }), lastUpdateTime: Date()) completion(latestData) } From 9d4690b130e27cf002a9fae040f1129606136c89 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 6 Feb 2023 16:25:58 +0800 Subject: [PATCH 2/2] Fixes compiler warnings related to the widget --- Shared/Widget/WidgetDataEncoder.swift | 2 +- Widget/Widget Views/StarredWidget.swift | 2 +- Widget/Widget Views/TodayWidget.swift | 2 +- Widget/Widget Views/UnreadWidget.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index ac4ba2768..c624e725e 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -69,7 +69,7 @@ public final class WidgetDataEncoder { @available(iOS 14, *) private func encodeWidgetData(completion: @escaping (WidgetData?) -> Void) { - var dispatchGroup = DispatchGroup() + let dispatchGroup = DispatchGroup() var groupError: Error? = nil var unread = [LatestArticle]() diff --git a/Widget/Widget Views/StarredWidget.swift b/Widget/Widget Views/StarredWidget.swift index 6667e29f1..cd3b3e72d 100644 --- a/Widget/Widget Views/StarredWidget.swift +++ b/Widget/Widget Views/StarredWidget.swift @@ -37,7 +37,7 @@ struct StarredWidgetView : View { Spacer() VStack(alignment:.leading, spacing: 0) { - ForEach(0..