Remember last selected account on OPML import. Issue #661

This commit is contained in:
Maurice Parker 2019-05-21 14:56:41 -05:00
parent a2a0586a32
commit af19b6dee0
2 changed files with 20 additions and 3 deletions

View File

@ -28,6 +28,7 @@ struct AppDefaults {
static let refreshInterval = "refreshInterval"
static let addFeedAccountID = "addFeedAccountID"
static let addFolderAccountID = "addFolderAccountID"
static let importOPMLAccountID = "importOPMLAccountID"
// Hidden prefs
static let showTitleOnMainWindow = "KafasisTitleMode"
@ -99,6 +100,15 @@ struct AppDefaults {
}
}
static var importOPMLAccountID: String? {
get {
return string(for: Key.importOPMLAccountID)
}
set {
setString(for: Key.importOPMLAccountID, newValue)
}
}
static var showTitleOnMainWindow: Bool {
return bool(for: Key.showTitleOnMainWindow)
}

View File

@ -19,17 +19,23 @@ class ImportOPMLWindowController: NSWindowController {
}
override func windowDidLoad() {
accountPopUpButton.removeAllItems()
let menu = NSMenu()
accountPopUpButton.menu = menu
for oneAccount in AccountManager.shared.sortedActiveAccounts {
let oneMenuItem = NSMenuItem()
oneMenuItem.title = oneAccount.nameForDisplay
oneMenuItem.representedObject = oneAccount
menu.addItem(oneMenuItem)
if oneAccount.accountID == AppDefaults.importOPMLAccountID {
accountPopUpButton.select(oneMenuItem)
}
}
accountPopUpButton.menu = menu
}
// MARK: API
@ -60,6 +66,7 @@ class ImportOPMLWindowController: NSWindowController {
}
let account = menuItem.representedObject as! Account
AppDefaults.importOPMLAccountID = account.accountID
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
importOPML(account: account)