Fix timeline so that it works with most recent AppDefaults code
This commit is contained in:
parent
d15dbe18ef
commit
313d3df573
|
@ -27,6 +27,7 @@ struct MainApp: App {
|
|||
SceneNavigationView()
|
||||
.frame(minWidth: 600, idealWidth: 1000, maxWidth: .infinity, minHeight: 600, idealHeight: 700, maxHeight: .infinity)
|
||||
.environmentObject(sceneModel)
|
||||
.environmentObject(defaults)
|
||||
.toolbar {
|
||||
|
||||
ToolbarItem {
|
||||
|
@ -144,6 +145,7 @@ struct MainApp: App {
|
|||
WindowGroup {
|
||||
SceneNavigationView()
|
||||
.environmentObject(sceneModel)
|
||||
.environmentObject(defaults)
|
||||
}.commands {
|
||||
CommandGroup(after: .newItem, addition: {
|
||||
Button("New Feed", action: {})
|
||||
|
|
|
@ -10,7 +10,9 @@ import SwiftUI
|
|||
|
||||
struct TimelineItemView: View {
|
||||
|
||||
@EnvironmentObject var defaults: AppDefaults
|
||||
@StateObject var articleIconImageLoader = ArticleIconImageLoader()
|
||||
|
||||
var timelineItem: TimelineItem
|
||||
|
||||
var body: some View {
|
||||
|
@ -19,12 +21,12 @@ struct TimelineItemView: View {
|
|||
TimelineItemStatusView(status: timelineItem.status)
|
||||
if let image = articleIconImageLoader.image {
|
||||
IconImageView(iconImage: image)
|
||||
.frame(width: AppDefaults.timelineIconSize.size.width, height: AppDefaults.timelineIconSize.size.height, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
.frame(width: CGFloat(defaults.timelineIconSize), height: CGFloat(defaults.timelineIconSize), alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
VStack {
|
||||
Text(verbatim: timelineItem.article.title ?? "N/A")
|
||||
.fontWeight(.semibold)
|
||||
.lineLimit(AppDefaults.timelineNumberOfLines)
|
||||
.lineLimit(defaults.timelineNumberOfLines)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.trailing, 4)
|
||||
Spacer()
|
||||
|
|
|
@ -29,7 +29,7 @@ class TimelineModel: ObservableObject {
|
|||
|
||||
private var articles = [Article]()
|
||||
|
||||
private var sortDirection = AppDefaults.timelineSortDirection {
|
||||
private var sortDirection = AppDefaults.shared.timelineSortDirection {
|
||||
didSet {
|
||||
if sortDirection != oldValue {
|
||||
sortParametersDidChange()
|
||||
|
@ -37,7 +37,7 @@ class TimelineModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
private var groupByFeed = AppDefaults.timelineGroupByFeed {
|
||||
private var groupByFeed = AppDefaults.shared.timelineGroupByFeed {
|
||||
didSet {
|
||||
if groupByFeed != oldValue {
|
||||
sortParametersDidChange()
|
||||
|
@ -111,7 +111,7 @@ private extension TimelineModel {
|
|||
}
|
||||
|
||||
func replaceArticles(with unsortedArticles: Set<Article>) {
|
||||
articles = Array(unsortedArticles).sortedByDate(sortDirection, groupByFeed: groupByFeed)
|
||||
articles = Array(unsortedArticles).sortedByDate(sortDirection ? .orderedDescending : .orderedAscending, groupByFeed: groupByFeed)
|
||||
timelineItems = articles.map { TimelineItem(article: $0) }
|
||||
|
||||
// TODO: Update unread counts and other item done in didSet on AppKit
|
||||
|
|
Loading…
Reference in New Issue