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:
parent
b1303661b2
commit
fb79309f95
|
@ -35,10 +35,18 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
// MARK: API
|
// MARK: API
|
||||||
|
|
||||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||||
|
|
||||||
self.hostWindow = hostWindow
|
self.hostWindow = hostWindow
|
||||||
|
|
||||||
|
if AccountManager.shared.activeAccounts.count == 1 {
|
||||||
|
let account = AccountManager.shared.activeAccounts.first!
|
||||||
|
exportOPML(account: account)
|
||||||
|
} else {
|
||||||
hostWindow.beginSheet(window!)
|
hostWindow.beginSheet(window!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
|
||||||
@IBAction func cancel(_ sender: Any) {
|
@IBAction func cancel(_ sender: Any) {
|
||||||
|
@ -50,9 +58,14 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
guard let menuItem = accountPopUpButton.selectedItem else {
|
guard let menuItem = accountPopUpButton.selectedItem else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let account = menuItem.representedObject as! Account
|
|
||||||
|
|
||||||
|
let account = menuItem.representedObject as! Account
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
|
exportOPML(account: account)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportOPML(account: Account) {
|
||||||
|
|
||||||
let panel = NSSavePanel()
|
let panel = NSSavePanel()
|
||||||
panel.allowedFileTypes = ["opml"]
|
panel.allowedFileTypes = ["opml"]
|
||||||
|
@ -79,7 +92,6 @@ class ExportOPMLWindowController: NSWindowController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,18 @@ class ImportOPMLWindowController: NSWindowController {
|
||||||
// MARK: API
|
// MARK: API
|
||||||
|
|
||||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||||
|
|
||||||
self.hostWindow = hostWindow
|
self.hostWindow = hostWindow
|
||||||
|
|
||||||
|
if AccountManager.shared.activeAccounts.count == 1 {
|
||||||
|
let account = AccountManager.shared.activeAccounts.first!
|
||||||
|
importOPML(account: account)
|
||||||
|
} else {
|
||||||
hostWindow.beginSheet(window!)
|
hostWindow.beginSheet(window!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
|
||||||
@IBAction func cancel(_ sender: Any) {
|
@IBAction func cancel(_ sender: Any) {
|
||||||
|
@ -50,9 +58,14 @@ class ImportOPMLWindowController: NSWindowController {
|
||||||
guard let menuItem = accountPopUpButton.selectedItem else {
|
guard let menuItem = accountPopUpButton.selectedItem else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let account = menuItem.representedObject as! Account
|
|
||||||
|
|
||||||
|
let account = menuItem.representedObject as! Account
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
|
importOPML(account: account)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func importOPML(account: Account) {
|
||||||
|
|
||||||
let panel = NSOpenPanel()
|
let panel = NSOpenPanel()
|
||||||
panel.canDownloadUbiquitousContents = true
|
panel.canDownloadUbiquitousContents = true
|
||||||
|
|
Loading…
Reference in New Issue