Enable always on Reader View for feeds
This commit is contained in:
parent
4e7ef7271a
commit
9d54a1de74
|
@ -15,6 +15,7 @@ import RSWeb
|
|||
enum DetailState: Equatable {
|
||||
case noSelection
|
||||
case multipleSelection
|
||||
case loading
|
||||
case article(Article)
|
||||
case extracted(Article, ExtractedArticle)
|
||||
}
|
||||
|
|
|
@ -184,6 +184,8 @@ private extension DetailWebViewController {
|
|||
rendering = ArticleRenderer.noSelectionHTML(style: style)
|
||||
case .multipleSelection:
|
||||
rendering = ArticleRenderer.multipleSelectionHTML(style: style)
|
||||
case .loading:
|
||||
rendering = ArticleRenderer.loadingHTML(style: style)
|
||||
case .article(let article):
|
||||
rendering = ArticleRenderer.articleHTML(article: article, style: style)
|
||||
case .extracted(let article, let extractedArticle):
|
||||
|
|
|
@ -329,11 +329,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
detailViewController?.setState(detailState, mode: timelineSourceMode)
|
||||
}
|
||||
} else {
|
||||
if let extractor = ArticleExtractor(currentLink) {
|
||||
extractor.delegate = self
|
||||
extractor.process()
|
||||
articleExtractor = extractor
|
||||
}
|
||||
startArticleExtractorForCurrentLink()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -453,18 +449,24 @@ extension MainWindowController: SidebarDelegate {
|
|||
extension MainWindowController: TimelineContainerViewControllerDelegate {
|
||||
|
||||
func timelineSelectionDidChange(_: TimelineContainerViewController, articles: [Article]?, mode: TimelineSourceMode) {
|
||||
|
||||
articleExtractor?.cancel()
|
||||
articleExtractor = nil
|
||||
isShowingExtractedArticle = false
|
||||
|
||||
makeToolbarValidate()
|
||||
|
||||
let detailState: DetailState
|
||||
if let articles = articles {
|
||||
detailState = articles.count == 1 ? .article(articles.first!) : .multipleSelection
|
||||
}
|
||||
else {
|
||||
if articles.count == 1 {
|
||||
if articles.first?.feed?.isArticleExtractorAlwaysOn ?? false {
|
||||
detailState = .loading
|
||||
startArticleExtractorForCurrentLink()
|
||||
} else {
|
||||
detailState = .article(articles.first!)
|
||||
}
|
||||
} else {
|
||||
detailState = .multipleSelection
|
||||
}
|
||||
} else {
|
||||
detailState = .noSelection
|
||||
}
|
||||
|
||||
|
@ -833,6 +835,14 @@ private extension MainWindowController {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func startArticleExtractorForCurrentLink() {
|
||||
if let link = currentLink, let extractor = ArticleExtractor(link) {
|
||||
extractor.delegate = self
|
||||
extractor.process()
|
||||
articleExtractor = extractor
|
||||
}
|
||||
}
|
||||
|
||||
func saveSplitViewState() {
|
||||
// TODO: Update this for multiple windows.
|
||||
|
|
|
@ -56,6 +56,11 @@ struct ArticleRenderer {
|
|||
return (renderer.styleString(), renderer.multipleSelectionHTML)
|
||||
}
|
||||
|
||||
static func loadingHTML(style: ArticleStyle) -> Rendering {
|
||||
let renderer = ArticleRenderer(article: nil, extractedArticle: nil, style: style)
|
||||
return (renderer.styleString(), renderer.loadingHTML)
|
||||
}
|
||||
|
||||
static func noSelectionHTML(style: ArticleStyle) -> Rendering {
|
||||
let renderer = ArticleRenderer(article: nil, extractedArticle: nil, style: style)
|
||||
return (renderer.styleString(), renderer.noSelectionHTML)
|
||||
|
@ -81,6 +86,11 @@ private extension ArticleRenderer {
|
|||
return renderHTML(withBody: body)
|
||||
}
|
||||
|
||||
private var loadingHTML: String {
|
||||
let body = "<h3 class='systemMessage'>Loading...</h3>"
|
||||
return renderHTML(withBody: body)
|
||||
}
|
||||
|
||||
private var noSelectionHTML: String {
|
||||
let body = "<h3 class='systemMessage'>No selection</h3>"
|
||||
return renderHTML(withBody: body)
|
||||
|
|
Loading…
Reference in New Issue