Launch with correct views instead of using placeholder text views
This commit is contained in:
parent
be60b112d0
commit
40e0a1b676
|
@ -43,6 +43,7 @@ final class SceneModel: ObservableObject {
|
|||
func startup() {
|
||||
sidebarModel.delegate = self
|
||||
timelineModel.delegate = self
|
||||
timelineModel.startup()
|
||||
|
||||
self.articleIconSchemeHandler = ArticleIconSchemeHandler(sceneModel: self)
|
||||
self.webViewProvider = WebViewProvider(articleIconSchemeHandler: self.articleIconSchemeHandler!)
|
||||
|
@ -103,6 +104,10 @@ extension SceneModel: SidebarModelDelegate {
|
|||
|
||||
extension SceneModel: TimelineModelDelegate {
|
||||
|
||||
var selectedFeeds: Published<[Feed]>.Publisher {
|
||||
return sidebarModel.$selectedFeeds
|
||||
}
|
||||
|
||||
func timelineRequestedWebFeedSelection(_: TimelineModel, webFeed: WebFeed) {
|
||||
}
|
||||
|
||||
|
|
|
@ -32,22 +32,13 @@ struct SceneNavigationView: View {
|
|||
|
||||
#if os(iOS)
|
||||
if horizontalSizeClass != .compact {
|
||||
Text("Timeline")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
TimelineContainerView()
|
||||
}
|
||||
#else
|
||||
Text("Timeline")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
TimelineContainerView()
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
Text("None Selected")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.toolbar { Spacer() }
|
||||
#else
|
||||
Text("None Selected")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
#endif
|
||||
ArticleContainerView()
|
||||
}
|
||||
.environmentObject(sceneModel)
|
||||
.onAppear {
|
||||
|
|
|
@ -46,7 +46,7 @@ struct SidebarView: View {
|
|||
.help(sidebarModel.isReadFiltered ? "Show Read Feeds" : "Filter Read Feeds")
|
||||
}
|
||||
ZStack(alignment: .bottom) {
|
||||
NavigationLink(destination: TimelineContainerView(feeds: sidebarModel.selectedFeeds), isActive: $navigate) {
|
||||
NavigationLink(destination: TimelineContainerView(), isActive: $navigate) {
|
||||
EmptyView()
|
||||
}.hidden()
|
||||
List(selection: $sidebarModel.selectedFeedIdentifiers) {
|
||||
|
@ -194,7 +194,7 @@ struct SidebarView: View {
|
|||
#else
|
||||
ZStack {
|
||||
SidebarItemView(sidebarItem: sidebarItem)
|
||||
NavigationLink(destination: TimelineContainerView(feeds: sidebarModel.selectedFeeds),
|
||||
NavigationLink(destination: TimelineContainerView(),
|
||||
tag: sidebarItem.feed!.feedID!,
|
||||
selection: $sidebarModel.selectedFeedIdentifier) {
|
||||
EmptyView()
|
||||
|
|
|
@ -13,20 +13,14 @@ struct TimelineContainerView: View {
|
|||
|
||||
@Environment(\.undoManager) var undoManager
|
||||
@EnvironmentObject private var sceneModel: SceneModel
|
||||
var feeds: [Feed]? = nil
|
||||
|
||||
@ViewBuilder var body: some View {
|
||||
if let feeds = feeds {
|
||||
TimelineView()
|
||||
.modifier(TimelineToolbarModifier())
|
||||
.environmentObject(sceneModel.timelineModel)
|
||||
.onAppear {
|
||||
sceneModel.timelineModel.undoManager = undoManager
|
||||
sceneModel.timelineModel.fetchArticles(feeds: feeds)
|
||||
}
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
TimelineView()
|
||||
.modifier(TimelineToolbarModifier())
|
||||
.environmentObject(sceneModel.timelineModel)
|
||||
.onAppear {
|
||||
sceneModel.timelineModel.undoManager = undoManager
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import Account
|
|||
import Articles
|
||||
|
||||
protocol TimelineModelDelegate: class {
|
||||
var selectedFeeds: Published<[Feed]>.Publisher { get }
|
||||
func timelineRequestedWebFeedSelection(_: TimelineModel, webFeed: WebFeed)
|
||||
}
|
||||
|
||||
|
@ -35,6 +36,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
var undoManager: UndoManager?
|
||||
var undoableCommands = [UndoableCommand]()
|
||||
|
||||
private var selectedFeedsCancellable: AnyCancellable?
|
||||
private var selectedArticleIDsCancellable: AnyCancellable?
|
||||
private var selectedArticleIDCancellable: AnyCancellable?
|
||||
private var selectedArticlesCancellable: AnyCancellable?
|
||||
|
@ -66,6 +68,7 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var groupByFeed = AppDefaults.shared.timelineGroupByFeed {
|
||||
didSet {
|
||||
if groupByFeed != oldValue {
|
||||
|
@ -74,10 +77,16 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
func startup() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
|
||||
|
||||
// TODO: This should be rewritten to use Combine correctly
|
||||
selectedFeedsCancellable = delegate?.selectedFeeds.sink { [weak self] feeds in
|
||||
guard let self = self else { return }
|
||||
self.fetchArticles(feeds: feeds)
|
||||
}
|
||||
|
||||
// TODO: This should be rewritten to use Combine correctly
|
||||
selectedArticleIDsCancellable = $selectedArticleIDs.sink { [weak self] articleIDs in
|
||||
guard let self = self else { return }
|
||||
|
@ -106,19 +115,6 @@ class TimelineModel: ObservableObject, UndoableCommandRunner {
|
|||
|
||||
// MARK: API
|
||||
|
||||
func fetchArticles(feeds: [Feed]) {
|
||||
self.feeds = feeds
|
||||
|
||||
if feeds.count == 1 {
|
||||
nameForDisplay = feeds.first!.nameForDisplay
|
||||
} else {
|
||||
nameForDisplay = NSLocalizedString("Multiple", comment: "Multiple Feeds")
|
||||
}
|
||||
|
||||
resetReadFilter()
|
||||
fetchAndReplaceArticlesAsync()
|
||||
}
|
||||
|
||||
func toggleReadFilter() {
|
||||
guard let filter = isReadFiltered, let feedID = feeds.first?.feedID else { return }
|
||||
readFilterEnabledTable[feedID] = !filter
|
||||
|
@ -383,6 +379,19 @@ private extension TimelineModel {
|
|||
|
||||
// MARK: Article Fetching
|
||||
|
||||
func fetchArticles(feeds: [Feed]) {
|
||||
self.feeds = feeds
|
||||
|
||||
if feeds.count == 1 {
|
||||
nameForDisplay = feeds.first!.nameForDisplay
|
||||
} else {
|
||||
nameForDisplay = NSLocalizedString("Multiple", comment: "Multiple Feeds")
|
||||
}
|
||||
|
||||
resetReadFilter()
|
||||
fetchAndReplaceArticlesAsync()
|
||||
}
|
||||
|
||||
func fetchAndReplaceArticlesAsync() {
|
||||
var fetchers = feeds as [ArticleFetcher]
|
||||
if let fetcher = exceptionArticleFetcher {
|
||||
|
|
Loading…
Reference in New Issue