mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #3792 from stuartbreckenridge/widget-article-fix
Adds sorting to widget article arrays
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user