mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-27 09:21:21 +01:00
Merge pull request #2977 from stuartbreckenridge/disable-reader-view
Disable reader view
This commit is contained in:
commit
facfb6fb4b
@ -152,9 +152,14 @@ public final class WebFeed: Feed, Renamable, Hashable {
|
||||
|
||||
public var isArticleExtractorAlwaysOn: Bool? {
|
||||
get {
|
||||
if isFeedProvider == true { return false } // not an option for FeedProviders
|
||||
return metadata.isArticleExtractorAlwaysOn
|
||||
}
|
||||
set {
|
||||
if isFeedProvider == true {
|
||||
metadata.isArticleExtractorAlwaysOn = false
|
||||
return
|
||||
}
|
||||
metadata.isArticleExtractorAlwaysOn = newValue
|
||||
}
|
||||
}
|
||||
@ -220,6 +225,21 @@ public final class WebFeed: Feed, Renamable, Hashable {
|
||||
postUnreadCountDidChangeNotification()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Feed Provider
|
||||
public var isFeedProvider: Bool {
|
||||
get {
|
||||
guard let webfeedURL = URL(string: url),
|
||||
let components = URLComponents(url: webfeedURL, resolvingAgainstBaseURL: false) else {
|
||||
return false
|
||||
}
|
||||
|
||||
if FeedProviderManager.shared.best(for: components) == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var metadata: WebFeedMetadata
|
||||
|
||||
|
@ -140,6 +140,9 @@ private extension WebFeedInspectorViewController {
|
||||
updateIsReaderViewAlwaysOn()
|
||||
windowTitle = feed?.nameForDisplay ?? NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
|
||||
view.needsLayout = true
|
||||
if let webfeed = feed {
|
||||
webfeed.isFeedProvider ? (isReaderViewAlwaysOnCheckBox?.isEnabled = false) : (isReaderViewAlwaysOnCheckBox?.isEnabled = true)
|
||||
}
|
||||
}
|
||||
|
||||
func updateImage() {
|
||||
|
@ -1061,6 +1061,7 @@ private extension MainWindowController {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if #available(macOS 11.0, *) {
|
||||
|
||||
guard let toolbarItem = item as? NSToolbarItem, let toolbarButton = toolbarItem.view as? ArticleExtractorButton else {
|
||||
@ -1069,6 +1070,15 @@ private extension MainWindowController {
|
||||
}
|
||||
return currentLink != nil
|
||||
}
|
||||
|
||||
if let webfeed = currentTimelineViewController?.selectedArticles.first?.webFeed {
|
||||
if webfeed.isFeedProvider {
|
||||
toolbarButton.isEnabled = false
|
||||
return false
|
||||
} else {
|
||||
toolbarButton.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
guard let state = articleExtractor?.state else {
|
||||
toolbarButton.buttonState = .off
|
||||
@ -1093,6 +1103,15 @@ private extension MainWindowController {
|
||||
return currentLink != nil
|
||||
}
|
||||
|
||||
if let webfeed = currentTimelineViewController?.selectedArticles.first?.webFeed {
|
||||
if webfeed.isFeedProvider {
|
||||
toolbarButton.isEnabled = false
|
||||
return false
|
||||
} else {
|
||||
toolbarButton.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
toolbarButton.state = isShowingExtractedArticle ? .on : .off
|
||||
|
||||
guard let state = articleExtractor?.state else {
|
||||
|
@ -240,15 +240,20 @@ private extension SidebarViewController {
|
||||
}
|
||||
menu.addItem(notificationMenuItem)
|
||||
|
||||
let articleExtractorText = NSLocalizedString("Always Use Reader View", comment: "Always Use Reader View")
|
||||
let articleExtractorMenuItem = menuItem(articleExtractorText, #selector(toggleArticleExtractorFromContextMenu(_:)), webFeed)
|
||||
|
||||
if webFeed.isArticleExtractorAlwaysOn == nil || webFeed.isArticleExtractorAlwaysOn! == false {
|
||||
articleExtractorMenuItem.state = .off
|
||||
} else {
|
||||
articleExtractorMenuItem.state = .on
|
||||
if !webFeed.isFeedProvider {
|
||||
let articleExtractorText = NSLocalizedString("Always Use Reader View", comment: "Always Use Reader View")
|
||||
let articleExtractorMenuItem = menuItem(articleExtractorText, #selector(toggleArticleExtractorFromContextMenu(_:)), webFeed)
|
||||
|
||||
if webFeed.isArticleExtractorAlwaysOn == nil || webFeed.isArticleExtractorAlwaysOn! == false {
|
||||
articleExtractorMenuItem.state = .off
|
||||
} else {
|
||||
articleExtractorMenuItem.state = .on
|
||||
}
|
||||
menu.addItem(articleExtractorMenuItem)
|
||||
}
|
||||
menu.addItem(articleExtractorMenuItem)
|
||||
|
||||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
menu.addItem(renameMenuItem(webFeed))
|
||||
|
@ -92,7 +92,7 @@ class ArticleViewController: UIViewController {
|
||||
|
||||
articleExtractorButton.addTarget(self, action: #selector(toggleArticleExtractor(_:)), for: .touchUpInside)
|
||||
toolbarItems?.insert(UIBarButtonItem(customView: articleExtractorButton), at: 6)
|
||||
|
||||
|
||||
pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [:])
|
||||
pageViewController.delegate = self
|
||||
pageViewController.dataSource = self
|
||||
@ -179,7 +179,11 @@ class ArticleViewController: UIViewController {
|
||||
starBarButtonItem.isEnabled = true
|
||||
|
||||
let permalinkPresent = article.preferredLink != nil
|
||||
articleExtractorButton.isEnabled = permalinkPresent && !AppDefaults.shared.isDeveloperBuild
|
||||
var isFeedProvider = false
|
||||
if let webfeed = article.webFeed {
|
||||
isFeedProvider = webfeed.isFeedProvider
|
||||
}
|
||||
articleExtractorButton.isEnabled = permalinkPresent && !AppDefaults.shared.isDeveloperBuild && !isFeedProvider
|
||||
actionBarButtonItem.isEnabled = permalinkPresent
|
||||
|
||||
if article.status.read {
|
||||
|
@ -48,7 +48,14 @@ class WebFeedInspectorViewController: UITableViewController {
|
||||
nameTextField.text = webFeed.nameForDisplay
|
||||
|
||||
notifyAboutNewArticlesSwitch.setOn(webFeed.isNotifyAboutNewArticles ?? false, animated: false)
|
||||
alwaysShowReaderViewSwitch.setOn(webFeed.isArticleExtractorAlwaysOn ?? false, animated: false)
|
||||
|
||||
if webFeed.isFeedProvider {
|
||||
alwaysShowReaderViewSwitch.isOn = false
|
||||
alwaysShowReaderViewSwitch.isEnabled = false
|
||||
} else {
|
||||
alwaysShowReaderViewSwitch.setOn(webFeed.isArticleExtractorAlwaysOn ?? false, animated: false)
|
||||
}
|
||||
|
||||
|
||||
homePageLabel.text = webFeed.homePageURL?.decodedURLString
|
||||
feedURLLabel.text = webFeed.url.decodedURLString
|
||||
|
Loading…
x
Reference in New Issue
Block a user