Change the Inspectors to use the correct API's so that the sync services get updated. Fixes #2661
This commit is contained in:
parent
08e772cbd1
commit
336f40db7f
|
@ -27,6 +27,7 @@ final class FolderInspectorViewController: NSViewController, Inspector {
|
||||||
let isFallbackInspector = false
|
let isFallbackInspector = false
|
||||||
var objects: [Any]? {
|
var objects: [Any]? {
|
||||||
didSet {
|
didSet {
|
||||||
|
renameFolderIfNecessary()
|
||||||
updateFolder()
|
updateFolder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,16 +44,17 @@ final class FolderInspectorViewController: NSViewController, Inspector {
|
||||||
// MARK: NSViewController
|
// MARK: NSViewController
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|
||||||
updateUI()
|
updateUI()
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidDisappear() {
|
||||||
|
renameFolderIfNecessary()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Notifications
|
// MARK: Notifications
|
||||||
|
|
||||||
@objc func displayNameDidChange(_ note: Notification) {
|
@objc func displayNameDidChange(_ note: Notification) {
|
||||||
|
|
||||||
guard let updatedFolder = note.object as? Folder, updatedFolder == folder else {
|
guard let updatedFolder = note.object as? Folder, updatedFolder == folder else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -63,19 +65,9 @@ final class FolderInspectorViewController: NSViewController, Inspector {
|
||||||
extension FolderInspectorViewController: NSTextFieldDelegate {
|
extension FolderInspectorViewController: NSTextFieldDelegate {
|
||||||
|
|
||||||
func controlTextDidEndEditing(_ obj: Notification) {
|
func controlTextDidEndEditing(_ obj: Notification) {
|
||||||
|
renameFolderIfNecessary()
|
||||||
|
}
|
||||||
|
|
||||||
guard let folder = folder, let nameTextField = nameTextField else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
folder.rename(to: nameTextField.stringValue) { result in
|
|
||||||
switch result {
|
|
||||||
case .success:
|
|
||||||
break
|
|
||||||
case .failure(let error):
|
|
||||||
NSApplication.shared.presentError(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension FolderInspectorViewController {
|
private extension FolderInspectorViewController {
|
||||||
|
@ -106,4 +98,20 @@ private extension FolderInspectorViewController {
|
||||||
}
|
}
|
||||||
windowTitle = folder?.nameForDisplay ?? NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
|
windowTitle = folder?.nameForDisplay ?? NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renameFolderIfNecessary() {
|
||||||
|
guard let folder = folder,
|
||||||
|
let account = folder.account,
|
||||||
|
let nameTextField = nameTextField,
|
||||||
|
folder.nameForDisplay != nameTextField.stringValue else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
account.renameFolder(folder, to: nameTextField.stringValue) { [weak self] result in
|
||||||
|
if case .failure(let error) = result {
|
||||||
|
self?.presentError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
|
||||||
let isFallbackInspector = false
|
let isFallbackInspector = false
|
||||||
var objects: [Any]? {
|
var objects: [Any]? {
|
||||||
didSet {
|
didSet {
|
||||||
|
renameWebFeedIfNecessary()
|
||||||
updateFeed()
|
updateFeed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,10 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
|
||||||
updateNotificationSettings()
|
updateNotificationSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidDisappear() {
|
||||||
|
renameWebFeedIfNecessary()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
@IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) {
|
@IBAction func isNotifyAboutNewArticlesChanged(_ sender: Any) {
|
||||||
guard userNotificationSettings != nil else {
|
guard userNotificationSettings != nil else {
|
||||||
|
@ -108,12 +113,8 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
|
||||||
|
|
||||||
extension WebFeedInspectorViewController: NSTextFieldDelegate {
|
extension WebFeedInspectorViewController: NSTextFieldDelegate {
|
||||||
|
|
||||||
func controlTextDidChange(_ note: Notification) {
|
func controlTextDidEndEditing(_ note: Notification) {
|
||||||
guard let feed = feed, let nameTextField = nameTextField else {
|
renameWebFeedIfNecessary()
|
||||||
return
|
|
||||||
}
|
|
||||||
feed.editedName = nameTextField.stringValue
|
|
||||||
windowTitle = feed.editedName ?? NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -208,4 +209,19 @@ private extension WebFeedInspectorViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renameWebFeedIfNecessary() {
|
||||||
|
guard let feed = feed,
|
||||||
|
let account = feed.account,
|
||||||
|
let nameTextField = nameTextField,
|
||||||
|
feed.nameForDisplay != nameTextField.stringValue else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
account.renameWebFeed(feed, to: nameTextField.stringValue) { [weak self] result in
|
||||||
|
if case .failure(let error) = result {
|
||||||
|
self?.presentError(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue