Merge pull request #3792 from stuartbreckenridge/widget-article-fix

Adds sorting to widget article arrays
This commit is contained in:
Maurice Parker
2023-02-08 16:51:47 -08:00
committed by GitHub
4 changed files with 6 additions and 6 deletions

View File

@@ -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)
}

View File

@@ -37,7 +37,7 @@ struct StarredWidgetView : View {
Spacer()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ForEach(0..<maxCount(), id: \.self, content: { i in
if i != 0 {
Divider()
ArticleItemView(article: entry.widgetData.starredArticles[i],

View File

@@ -37,7 +37,7 @@ struct TodayWidgetView : View {
Spacer()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ForEach(0..<maxCount(), id: \.self, content: { i in
if i != 0 {
Divider()
ArticleItemView(article: entry.widgetData.todayArticles[i],

View File

@@ -37,7 +37,7 @@ struct UnreadWidgetView : View {
Spacer()
VStack(alignment:.leading, spacing: 0) {
ForEach(0..<maxCount(), content: { i in
ForEach(0..<maxCount(), id: \.self, content: { i in
if i != 0 {
Divider()
ArticleItemView(article: entry.widgetData.unreadArticles[i],