Save last used folder name when adding a feed. Issue #1462

This commit is contained in:
Maurice Parker 2020-02-27 11:27:41 -08:00
parent 7c060bb068
commit a465045888
2 changed files with 19 additions and 1 deletions

View File

@ -28,6 +28,7 @@ struct AppDefaults {
static let mainWindowWidths = "mainWindowWidths"
static let refreshInterval = "refreshInterval"
static let addFeedAccountID = "addFeedAccountID"
static let addFeedFolderName = "addFeedFolderName"
static let addFolderAccountID = "addFolderAccountID"
static let importOPMLAccountID = "importOPMLAccountID"
static let exportOPMLAccountID = "exportOPMLAccountID"
@ -109,6 +110,15 @@ struct AppDefaults {
}
}
static var addFeedFolderName: String? {
get {
return string(for: Key.addFeedFolderName)
}
set {
setString(for: Key.addFeedFolderName, newValue)
}
}
static var addFolderAccountID: String? {
get {
return string(for: Key.addFolderAccountID)

View File

@ -73,7 +73,13 @@ class AddFeedWindowController : NSWindowController {
FolderTreeMenu.select(account: account, folder: initialFolder, in: folderPopupButton)
} else if let accountID = AppDefaults.addFeedAccountID {
if let account = AccountManager.shared.existingAccount(with: accountID) {
FolderTreeMenu.select(account: account, folder: nil, in: folderPopupButton)
let folder: Folder? = {
if let folderName = AppDefaults.addFeedFolderName {
return account.ensureFolder(with: folderName)
}
return nil
}()
FolderTreeMenu.select(account: account, folder: folder, in: folderPopupButton)
}
}
@ -102,8 +108,10 @@ class AddFeedWindowController : NSWindowController {
let container = selectedContainer()!
if let selectedAccount = container as? Account {
AppDefaults.addFeedAccountID = selectedAccount.accountID
AppDefaults.addFeedFolderName = nil
} else if let selectedFolder = container as? Folder, let selectedAccount = selectedFolder.account {
AppDefaults.addFeedAccountID = selectedAccount.accountID
AppDefaults.addFeedFolderName = selectedFolder.name
}
delegate?.addFeedWindowController(self, userEnteredURL: url, userEnteredTitle: userEnteredTitle, container: container)