Change import and export OPML so that they don't prompt to select an account if only one is active

This commit is contained in:
Maurice Parker 2019-05-14 19:40:38 -05:00
parent b1303661b2
commit fb79309f95
2 changed files with 31 additions and 6 deletions

View File

@ -35,8 +35,16 @@ class ExportOPMLWindowController: NSWindowController {
// MARK: API
func runSheetOnWindow(_ hostWindow: NSWindow) {
self.hostWindow = hostWindow
hostWindow.beginSheet(window!)
if AccountManager.shared.activeAccounts.count == 1 {
let account = AccountManager.shared.activeAccounts.first!
exportOPML(account: account)
} else {
hostWindow.beginSheet(window!)
}
}
// MARK: Actions
@ -50,9 +58,14 @@ class ExportOPMLWindowController: NSWindowController {
guard let menuItem = accountPopUpButton.selectedItem else {
return
}
let account = menuItem.representedObject as! Account
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
exportOPML(account: account)
}
func exportOPML(account: Account) {
let panel = NSSavePanel()
panel.allowedFileTypes = ["opml"]
@ -79,7 +92,6 @@ class ExportOPMLWindowController: NSWindowController {
}
}
}
}

View File

@ -35,8 +35,16 @@ class ImportOPMLWindowController: NSWindowController {
// MARK: API
func runSheetOnWindow(_ hostWindow: NSWindow) {
self.hostWindow = hostWindow
hostWindow.beginSheet(window!)
if AccountManager.shared.activeAccounts.count == 1 {
let account = AccountManager.shared.activeAccounts.first!
importOPML(account: account)
} else {
hostWindow.beginSheet(window!)
}
}
// MARK: Actions
@ -50,9 +58,14 @@ class ImportOPMLWindowController: NSWindowController {
guard let menuItem = accountPopUpButton.selectedItem else {
return
}
let account = menuItem.representedObject as! Account
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
importOPML(account: account)
}
func importOPML(account: Account) {
let panel = NSOpenPanel()
panel.canDownloadUbiquitousContents = true