Continue renaming webFeed to feed.

This commit is contained in:
Brent Simmons
2024-11-02 11:08:58 -07:00
parent 2d3ef95619
commit 4fa4c6a541
95 changed files with 1156 additions and 1160 deletions

View File

@@ -13,11 +13,11 @@ import Account
extension MasterFeedViewController: UITableViewDragDelegate {
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
guard let node = coordinator.nodeFor(indexPath), let webFeed = node.representedObject as? Feed else {
guard let node = coordinator.nodeFor(indexPath), let feed = node.representedObject as? Feed else {
return [UIDragItem]()
}
let data = webFeed.url.data(using: .utf8)
let data = feed.url.data(using: .utf8)
let itemProvider = NSItemProvider()
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeURL as String, visibility: .ownProcess) { completion in

View File

@@ -31,8 +31,8 @@ extension MasterFeedViewController: UITableViewDropDelegate {
// Validate account specific behaviors...
if destAccount.behaviors.contains(.disallowFeedInMultipleFolders),
let sourceNode = session.localDragSession?.items.first?.localObject as? Node,
let sourceWebFeed = sourceNode.representedObject as? Feed,
sourceWebFeed.account?.accountID != destAccount.accountID && destAccount.hasFeed(withURL: sourceWebFeed.url) {
let sourceFeed = sourceNode.representedObject as? Feed,
sourceFeed.account?.accountID != destAccount.accountID && destAccount.hasFeed(withURL: sourceFeed.url) {
return UITableViewDropProposal(operation: .forbidden)
}
@@ -91,16 +91,16 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
}()
guard let destination = destinationContainer, let webFeed = dragNode.representedObject as? Feed else { return }
guard let destination = destinationContainer, let feed = dragNode.representedObject as? Feed else { return }
if source.account == destination.account {
moveWebFeedInAccount(feed: webFeed, sourceContainer: source, destinationContainer: destination)
moveFeedInAccount(feed: feed, sourceContainer: source, destinationContainer: destination)
} else {
moveWebFeedBetweenAccounts(feed: webFeed, sourceContainer: source, destinationContainer: destination)
moveFeedBetweenAccounts(feed: feed, sourceContainer: source, destinationContainer: destination)
}
}
func moveWebFeedInAccount(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
func moveFeedInAccount(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
guard sourceContainer !== destinationContainer else { return }
BatchUpdate.shared.start()
@@ -115,7 +115,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
}
}
func moveWebFeedBetweenAccounts(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
func moveFeedBetweenAccounts(feed: Feed, sourceContainer: Container, destinationContainer: Container) {
if let existingFeed = destinationContainer.account?.existingFeed(withURL: feed.url) {
@@ -123,7 +123,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
destinationContainer.account?.addFeed(existingFeed, to: destinationContainer) { result in
switch result {
case .success:
sourceContainer.account?.removeWebFeed(feed, from: sourceContainer) { result in
sourceContainer.account?.removeFeed(feed, from: sourceContainer) { result in
BatchUpdate.shared.end()
switch result {
case .success:
@@ -144,7 +144,7 @@ extension MasterFeedViewController: UITableViewDropDelegate {
destinationContainer.account?.createFeed(url: feed.url, name: feed.editedName, container: destinationContainer, validateFeed: false) { result in
switch result {
case .success:
sourceContainer.account?.removeWebFeed(feed, from: sourceContainer) { result in
sourceContainer.account?.removeFeed(feed, from: sourceContainer) { result in
BatchUpdate.shared.end()
switch result {
case .success:

View File

@@ -68,8 +68,8 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(webFeedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(webFeedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
@@ -129,19 +129,19 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
applyToAvailableCells(configureIcon)
}
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
guard let webFeed = note.userInfo?[UserInfoKey.feed] as? Feed else {
@objc func feedIconDidBecomeAvailable(_ note: Notification) {
guard let feed = note.userInfo?[UserInfoKey.feed] as? Feed else {
return
}
applyToCellsForRepresentedObject(webFeed, configureIcon(_:_:))
applyToCellsForRepresentedObject(feed, configureIcon(_:_:))
}
@objc func webFeedSettingDidChange(_ note: Notification) {
guard let webFeed = note.object as? Feed, let key = note.userInfo?[Feed.FeedSettingUserInfoKey] as? String else {
@objc func feedSettingDidChange(_ note: Notification) {
guard let feed = note.object as? Feed, let key = note.userInfo?[Feed.FeedSettingUserInfoKey] as? String else {
return
}
if key == Feed.FeedSettingKey.homePageURL || key == Feed.FeedSettingKey.faviconURL {
configureCellsForRepresentedObject(webFeed)
configureCellsForRepresentedObject(feed)
}
}
@@ -268,13 +268,13 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
renameAction.backgroundColor = UIColor.systemOrange
actions.append(renameAction)
if let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed {
if let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed {
let moreTitle = NSLocalizedString("More", comment: "More")
let moreAction = UIContextualAction(style: .normal, title: moreTitle) { [weak self] (action, view, completion) in
if let self = self {
let alert = UIAlertController(title: webFeed.nameForDisplay, message: nil, preferredStyle: .actionSheet)
let alert = UIAlertController(title: feed.nameForDisplay, message: nil, preferredStyle: .actionSheet)
if let popoverController = alert.popoverPresentationController {
popoverController.sourceView = view
popoverController.sourceRect = CGRect(x: view.frame.size.width/2, y: view.frame.size.height/2, width: 1, height: 1)
@@ -324,7 +324,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
return nil
}
if feed is Feed {
return makeWebFeedContextMenu(indexPath: indexPath, includeDeleteRename: true)
return makeFeedContextMenu(indexPath: indexPath, includeDeleteRename: true)
} else if feed is Folder {
return makeFolderContextMenu(indexPath: indexPath)
} else if feed is PseudoFeed {
@@ -439,9 +439,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel")
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel)
let addWebFeedActionTitle = NSLocalizedString("Add Web Feed", comment: "Add Web Feed")
let addWebFeedAction = UIAlertAction(title: addWebFeedActionTitle, style: .default) { _ in
self.coordinator.showAddWebFeed()
let addFeedActionTitle = NSLocalizedString("Add Feed", comment: "Add Feed")
let addFeedAction = UIAlertAction(title: addFeedActionTitle, style: .default) { _ in
self.coordinator.showAddFeed()
}
let addWebFolderdActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder")
@@ -449,7 +449,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
self.coordinator.showAddFolder()
}
alertController.addAction(addWebFeedAction)
alertController.addAction(addFeedAction)
alertController.addAction(addWebFolderAction)
alertController.addAction(cancelAction)
@@ -649,11 +649,11 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
var menuItems: [UIAction] = []
let addWebFeedActionTitle = NSLocalizedString("Add Feed", comment: "Add Feed")
let addWebFeedAction = UIAction(title: addWebFeedActionTitle, image: AppAssets.plus) { _ in
self.coordinator.showAddWebFeed()
let addFeedActionTitle = NSLocalizedString("Add Feed", comment: "Add Feed")
let addFeedAction = UIAction(title: addFeedActionTitle, image: AppAssets.plus) { _ in
self.coordinator.showAddFeed()
}
menuItems.append(addWebFeedAction)
menuItems.append(addFeedAction)
let addWebFolderActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder")
let addWebFolderAction = UIAction(title: addWebFolderActionTitle, image: AppAssets.folderOutlinePlus) { _ in
@@ -896,7 +896,7 @@ private extension MasterFeedViewController {
coordinator.collapse(node)
}
func makeWebFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration {
func makeFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration {
return UIContextMenuConfiguration(identifier: MasterFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] suggestedActions in
guard let self = self else { return nil }
@@ -1000,8 +1000,8 @@ private extension MasterFeedViewController {
}
func copyFeedPageAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: webFeed.url) else {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: feed.url) else {
return nil
}
@@ -1013,8 +1013,8 @@ private extension MasterFeedViewController {
}
func copyFeedPageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: webFeed.url) else {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let url = URL(string: feed.url) else {
return nil
}
@@ -1027,8 +1027,8 @@ private extension MasterFeedViewController {
}
func copyHomePageAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = webFeed.homePageURL,
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = feed.homePageURL,
let url = URL(string: homePageURL) else {
return nil
}
@@ -1041,8 +1041,8 @@ private extension MasterFeedViewController {
}
func copyHomePageAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = webFeed.homePageURL,
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
let homePageURL = feed.homePageURL,
let url = URL(string: homePageURL) else {
return nil
}
@@ -1056,14 +1056,14 @@ private extension MasterFeedViewController {
}
func markAllAsReadAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
webFeed.unreadCount > 0,
let articles = try? webFeed.fetchArticles(), let contentView = self.tableView.cellForRow(at: indexPath)?.contentView else {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed,
feed.unreadCount > 0,
let articles = try? feed.fetchArticles(), let contentView = self.tableView.cellForRow(at: indexPath)?.contentView else {
return nil
}
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, webFeed.nameForDisplay) as String
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay) as String
let cancel = {
completion(true)
}
@@ -1096,13 +1096,13 @@ private extension MasterFeedViewController {
}
func getInfoAction(indexPath: IndexPath) -> UIAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
return nil
}
let title = NSLocalizedString("Get Info", comment: "Get Info")
let action = UIAction(title: title, image: AppAssets.infoImage) { [weak self] action in
self?.coordinator.showFeedInspector(for: webFeed)
self?.coordinator.showFeedInspector(for: feed)
}
return action
}
@@ -1124,13 +1124,13 @@ private extension MasterFeedViewController {
}
func getInfoAlertAction(indexPath: IndexPath, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
guard let webFeed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
guard let feed = coordinator.nodeFor(indexPath)?.representedObject as? Feed else {
return nil
}
let title = NSLocalizedString("Get Info", comment: "Get Info")
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
self?.coordinator.showFeedInspector(for: webFeed)
self?.coordinator.showFeedInspector(for: feed)
completion(true)
}
return action
@@ -1196,8 +1196,8 @@ private extension MasterFeedViewController {
return
}
if let webFeed = feed as? Feed {
webFeed.rename(to: name) { result in
if let feed = feed as? Feed {
feed.rename(to: name) { result in
switch result {
case .success:
break