mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 09:18:18 +00:00
Simplify the confirmation for mark-all-as-read — drop the link to Settings.
This commit is contained in:
1 parent
bf58016574
commit
80075d1dc3
7 files changed
+20
-47
No files matched your search
@@ -896,9 +896,6 @@
|
||||
"Mark as Read" : {
|
||||
"comment" : "Command"
|
||||
},
|
||||
"Mark As Read" : {
|
||||
"comment" : "Mark As Read"
|
||||
},
|
||||
"Mark as Starred" : {
|
||||
"comment" : "Command"
|
||||
},
|
||||
@@ -1794,9 +1791,6 @@
|
||||
"You can enable NetNewsWire notifications in System Preferences." : {
|
||||
"comment" : "Notifications are not enabled."
|
||||
},
|
||||
"You can turn this confirmation off in Settings." : {
|
||||
"comment" : "You can turn this confirmation off in Settings."
|
||||
},
|
||||
"You must have at least one active account." : {
|
||||
"comment" : "Missing active account"
|
||||
},
|
||||
|
||||
@@ -629,7 +629,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
let title = NSLocalizedString("Mark All as Read", comment: "Command")
|
||||
let articlesToMark = coordinator.articles
|
||||
|
||||
MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
self?.coordinator.markAsReadAndShowSidebar(articlesToMark)
|
||||
}
|
||||
}
|
||||
@@ -1309,7 +1309,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
self?.coordinator.markAllAsRead(Array(articles), in: feed)
|
||||
completion(true)
|
||||
}
|
||||
@@ -1393,7 +1393,7 @@ extension MainFeedCollectionViewController {
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, sidebarItem.nameForDisplay) as String
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
let articles = sidebarItem.fetchUnreadArticles()
|
||||
self?.coordinator.markAllAsRead(Array(articles), in: sidebarItem)
|
||||
}
|
||||
@@ -1410,7 +1410,7 @@ extension MainFeedCollectionViewController {
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, account.nameForDisplay) as String
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
// If you don’t have this delay the screen flashes when it executes this code
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
let articles = account.fetchArticles(.unread())
|
||||
|
||||
@@ -536,7 +536,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
|
||||
let articlesToMark = coordinator.articles
|
||||
|
||||
if let source = sender as? UIBarButtonItem {
|
||||
MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: source) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: source) { [weak self] in
|
||||
self?.coordinator?.markAsReadAndShowSidebar(articlesToMark)
|
||||
}
|
||||
}
|
||||
@@ -549,7 +549,7 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
|
||||
return
|
||||
}
|
||||
|
||||
MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
self?.coordinator?.markAsReadAndShowSidebar(articlesToMark)
|
||||
}
|
||||
}
|
||||
@@ -1405,7 +1405,7 @@ extension MainTimelineViewController {
|
||||
let title = NSLocalizedString("Mark Above as Read", comment: "Command")
|
||||
let image = Assets.Images.markAboveAsRead
|
||||
let action = UIAction(title: title, image: image) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
self?.markAboveAsRead(article)
|
||||
}
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ extension MainTimelineViewController {
|
||||
let title = NSLocalizedString("Mark Below as Read", comment: "Command")
|
||||
let image = Assets.Images.markBelowAsRead
|
||||
let action = UIAction(title: title, image: image) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
self?.markBelowAsRead(article)
|
||||
}
|
||||
}
|
||||
@@ -1448,7 +1448,7 @@ extension MainTimelineViewController {
|
||||
}
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
self?.markAboveAsRead(article)
|
||||
completion(true)
|
||||
}
|
||||
@@ -1467,7 +1467,7 @@ extension MainTimelineViewController {
|
||||
}
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
self?.markBelowAsRead(article)
|
||||
completion(true)
|
||||
}
|
||||
@@ -1528,7 +1528,7 @@ extension MainTimelineViewController {
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
|
||||
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
self?.markAllAsRead(articles)
|
||||
}
|
||||
}
|
||||
@@ -1553,7 +1553,7 @@ extension MainTimelineViewController {
|
||||
}
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
self?.markAllAsRead(articles)
|
||||
completion(true)
|
||||
}
|
||||
|
||||
@@ -17,19 +17,18 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {}
|
||||
@MainActor struct MarkAsReadAlertController {
|
||||
|
||||
static func confirm<T>(_ controller: UIViewController?,
|
||||
coordinator: SceneCoordinator?,
|
||||
confirmTitle: String,
|
||||
sourceType: T,
|
||||
cancelCompletion: (() -> Void)? = nil,
|
||||
completion: @escaping () -> Void) where T: MarkAsReadAlertControllerSourceType {
|
||||
|
||||
guard let controller, let coordinator else {
|
||||
guard let controller else {
|
||||
completion()
|
||||
return
|
||||
}
|
||||
|
||||
if AppDefaults.confirmMarkAllAsRead {
|
||||
let alertController = MarkAsReadAlertController.alert(coordinator: coordinator, confirmTitle: confirmTitle, cancelCompletion: cancelCompletion, sourceType: sourceType) { _ in
|
||||
let alertController = MarkAsReadAlertController.alert(confirmTitle: confirmTitle, cancelCompletion: cancelCompletion, sourceType: sourceType) { _ in
|
||||
completion()
|
||||
}
|
||||
controller.present(alertController, animated: true)
|
||||
@@ -38,31 +37,20 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {}
|
||||
}
|
||||
}
|
||||
|
||||
private static func alert<T>(coordinator: SceneCoordinator,
|
||||
confirmTitle: String,
|
||||
private static func alert<T>(confirmTitle: String,
|
||||
cancelCompletion: (() -> Void)?,
|
||||
sourceType: T,
|
||||
completion: @escaping (UIAlertAction) -> Void) -> UIAlertController where T: MarkAsReadAlertControllerSourceType {
|
||||
|
||||
let title = NSLocalizedString("Mark As Read", comment: "Mark As Read")
|
||||
let message = NSLocalizedString("You can turn this confirmation off in Settings.",
|
||||
comment: "You can turn this confirmation off in Settings.")
|
||||
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel button")
|
||||
let settingsTitle = NSLocalizedString("Open Settings", comment: "Open Settings button")
|
||||
|
||||
let alertController = UIAlertController(title: title, message: message, preferredStyle: .actionSheet)
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) { _ in
|
||||
cancelCompletion?()
|
||||
}
|
||||
let settingsAction = UIAlertAction(title: settingsTitle, style: .default) { _ in
|
||||
Task { @MainActor in
|
||||
coordinator.showSettings(showTimelineSettings: true)
|
||||
}
|
||||
}
|
||||
let markAction = UIAlertAction(title: confirmTitle, style: .default, handler: completion)
|
||||
|
||||
alertController.addAction(markAction)
|
||||
alertController.addAction(settingsAction)
|
||||
alertController.addAction(cancelAction)
|
||||
|
||||
if let barButtonItem = sourceType as? UIBarButtonItem {
|
||||
|
||||
@@ -116,9 +116,9 @@ final class RootSplitViewController: UISplitViewController {
|
||||
// Anchor to the Mark All as Read button (keyboard shortcut has no source view).
|
||||
// <https://github.com/Ranchero-Software/NetNewsWire/issues/5370>
|
||||
if let markAllAsReadButton = (viewController(for: .supplementary) as? MainTimelineViewController)?.markAllAsReadButton {
|
||||
MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: markAllAsReadButton, completion: completion)
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: markAllAsReadButton, completion: completion)
|
||||
} else {
|
||||
MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: view as UIView, completion: completion)
|
||||
MarkAsReadAlertController.confirm(self, confirmTitle: title, sourceType: view as UIView, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1610,8 +1610,8 @@ struct SidebarItemNode: Hashable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
func showSettings(showTimelineSettings: Bool = false) {
|
||||
let settingsView = SettingsView(showTimelineSettings: showTimelineSettings, presentingParentController: rootSplitViewController)
|
||||
func showSettings() {
|
||||
let settingsView = SettingsView(presentingParentController: rootSplitViewController)
|
||||
let hostingController = UIHostingController(rootView: settingsView)
|
||||
hostingController.modalPresentationStyle = .formSheet
|
||||
rootSplitViewController.present(hostingController, animated: true)
|
||||
|
||||
@@ -13,8 +13,6 @@ import Account
|
||||
|
||||
struct SettingsView: View {
|
||||
|
||||
/// Pushes the Timeline screen on appearing, so a user can turn off the Mark All as Read confirmation.
|
||||
let showTimelineSettings: Bool
|
||||
/// Presents Settings, and presents what Settings hands off to after dismissing itself.
|
||||
let presentingParentController: RootSplitViewController?
|
||||
|
||||
@@ -22,7 +20,6 @@ struct SettingsView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
@State private var model = SettingsModel()
|
||||
@State private var path = [SettingsDestination]()
|
||||
@State private var didShowTimelineSettings = false
|
||||
@State private var opmlAccount: Account?
|
||||
@State private var isShowingOPMLImporter = false
|
||||
@State private var opmlExportURL: URL?
|
||||
@@ -105,12 +102,6 @@ struct SettingsView: View {
|
||||
destinationView(destination)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if showTimelineSettings && !didShowTimelineSettings {
|
||||
didShowTimelineSettings = true
|
||||
path.append(.timeline)
|
||||
}
|
||||
}
|
||||
.fileImporter(isPresented: $isShowingOPMLImporter, allowedContentTypes: Self.opmlContentTypes) { result in
|
||||
if case .success(let url) = result, let opmlAccount {
|
||||
importOPML(url, into: opmlAccount)
|
||||
|
||||
Reference in new issue
Block a user