diff --git a/Mac/MainWindow/OPML/ExportOPMLWindowController.swift b/Mac/MainWindow/OPML/ExportOPMLWindowController.swift index 86554200d..d9e997619 100644 --- a/Mac/MainWindow/OPML/ExportOPMLWindowController.swift +++ b/Mac/MainWindow/OPML/ExportOPMLWindowController.swift @@ -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 { } } - - } + } diff --git a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift index 9247d86f7..66b4c6420 100644 --- a/Mac/MainWindow/OPML/ImportOPMLWindowController.swift +++ b/Mac/MainWindow/OPML/ImportOPMLWindowController.swift @@ -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