From af19b6dee0aee534734e451a25cf803ea48014e6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 21 May 2019 14:56:41 -0500 Subject: [PATCH] Remember last selected account on OPML import. Issue #661 --- Mac/AppDefaults.swift | 10 ++++++++++ .../OPML/ImportOPMLWindowController.swift | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 755e43b73..aa1503428 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -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) } diff --git a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift index 66b4c6420..76038c293 100644 --- a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift +++ b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift @@ -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)