2020-06-28 21:21:43 +02:00
|
|
|
//
|
|
|
|
// SceneModel.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 6/28/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2020-06-29 00:43:20 +02:00
|
|
|
import Account
|
2020-07-07 04:14:05 +02:00
|
|
|
import Articles
|
2020-06-28 21:21:43 +02:00
|
|
|
|
|
|
|
final class SceneModel: ObservableObject {
|
|
|
|
|
2020-07-04 17:20:50 +02:00
|
|
|
@Published var refreshProgressState = RefreshProgressModel.State.none
|
|
|
|
|
2020-06-28 21:21:43 +02:00
|
|
|
var sidebarModel: SidebarModel?
|
2020-06-30 18:03:33 +02:00
|
|
|
var timelineModel: TimelineModel?
|
2020-07-02 22:30:50 +02:00
|
|
|
var articleModel: ArticleModel?
|
2020-06-28 21:21:43 +02:00
|
|
|
|
2020-07-06 02:49:07 +02:00
|
|
|
private var refreshProgressModel: RefreshProgressModel? = nil
|
2020-07-07 04:14:05 +02:00
|
|
|
private var _webViewProvider: WebViewProvider? = nil
|
2020-07-04 17:20:50 +02:00
|
|
|
|
2020-07-07 04:14:05 +02:00
|
|
|
// MARK: API
|
|
|
|
|
2020-07-06 02:49:07 +02:00
|
|
|
func startup() {
|
|
|
|
self.refreshProgressModel = RefreshProgressModel()
|
|
|
|
self.refreshProgressModel!.$state.assign(to: self.$refreshProgressState)
|
2020-07-07 04:14:05 +02:00
|
|
|
|
|
|
|
self._webViewProvider = WebViewProvider(sceneModel: self)
|
|
|
|
}
|
|
|
|
|
|
|
|
func articleFor(_ articleID: String) -> Article? {
|
|
|
|
return timelineModel?.articleFor(articleID)
|
2020-07-04 17:20:50 +02:00
|
|
|
}
|
2020-07-07 04:14:05 +02:00
|
|
|
|
2020-06-28 21:21:43 +02:00
|
|
|
}
|
2020-06-29 00:43:20 +02:00
|
|
|
|
|
|
|
// MARK: SidebarModelDelegate
|
|
|
|
|
|
|
|
extension SceneModel: SidebarModelDelegate {
|
|
|
|
|
2020-06-29 13:16:48 +02:00
|
|
|
func unreadCount(for feed: Feed) -> Int {
|
|
|
|
// TODO: Get the count from the timeline if Feed is the current timeline
|
|
|
|
return feed.unreadCount
|
|
|
|
}
|
|
|
|
|
2020-06-29 00:43:20 +02:00
|
|
|
}
|
2020-06-30 18:03:33 +02:00
|
|
|
|
|
|
|
// MARK: TimelineModelDelegate
|
|
|
|
|
|
|
|
extension SceneModel: TimelineModelDelegate {
|
|
|
|
|
|
|
|
func timelineRequestedWebFeedSelection(_: TimelineModel, webFeed: WebFeed) {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-02 22:30:50 +02:00
|
|
|
|
|
|
|
// MARK: ArticleModelDelegate
|
|
|
|
|
|
|
|
extension SceneModel: ArticleModelDelegate {
|
2020-07-07 04:14:05 +02:00
|
|
|
|
|
|
|
var webViewProvider: WebViewProvider? {
|
|
|
|
return _webViewProvider
|
|
|
|
}
|
|
|
|
|
|
|
|
func findPrevArticle(_: ArticleModel, article: Article) -> Article? {
|
|
|
|
return timelineModel?.findPrevArticle(article)
|
|
|
|
}
|
|
|
|
|
|
|
|
func findNextArticle(_: ArticleModel, article: Article) -> Article? {
|
|
|
|
return timelineModel?.findNextArticle(article)
|
|
|
|
}
|
|
|
|
|
|
|
|
func selectArticle(_: ArticleModel, article: Article) {
|
|
|
|
timelineModel?.selectArticle(article)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Private
|
2020-07-02 22:30:50 +02:00
|
|
|
|
2020-07-07 04:14:05 +02:00
|
|
|
private extension SceneModel {
|
2020-07-02 22:30:50 +02:00
|
|
|
|
|
|
|
}
|