Rename AccountManageer.localAccount to AccountManager.defaultAccount to make it different from other local accounts
This commit is contained in:
parent
a682a78820
commit
4bc7611721
|
@ -18,7 +18,7 @@ private let localAccountIdentifier = "OnMyMac"
|
||||||
public final class AccountManager: UnreadCountProvider {
|
public final class AccountManager: UnreadCountProvider {
|
||||||
|
|
||||||
public static let shared = AccountManager()
|
public static let shared = AccountManager()
|
||||||
public let localAccount: Account
|
public let defaultAccount: Account
|
||||||
private let accountsFolder = RSDataSubfolder(nil, "Accounts")!
|
private let accountsFolder = RSDataSubfolder(nil, "Accounts")!
|
||||||
private var accountsDictionary = [String: Account]()
|
private var accountsDictionary = [String: Account]()
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ public final class AccountManager: UnreadCountProvider {
|
||||||
abort()
|
abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
localAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
|
defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
|
||||||
accountsDictionary[localAccount.accountID] = localAccount
|
accountsDictionary[defaultAccount.accountID] = defaultAccount
|
||||||
|
|
||||||
readNonLocalAccountsFromDisk()
|
readNonLocalAccountsFromDisk()
|
||||||
|
|
||||||
|
@ -179,10 +179,10 @@ public final class AccountManager: UnreadCountProvider {
|
||||||
|
|
||||||
return accounts.sorted { (account1, account2) -> Bool in
|
return accounts.sorted { (account1, account2) -> Bool in
|
||||||
|
|
||||||
if account1 === localAccount {
|
if account1 === defaultAccount {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if account2 === localAccount {
|
if account2 === defaultAccount {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return (account1.nameForDisplay as NSString).localizedStandardCompare(account2.nameForDisplay) == .orderedAscending
|
return (account1.nameForDisplay as NSString).localizedStandardCompare(account2.nameForDisplay) == .orderedAscending
|
||||||
|
|
|
@ -117,7 +117,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||||
if isFirstRun {
|
if isFirstRun {
|
||||||
logDebugMessage("Is first run.")
|
logDebugMessage("Is first run.")
|
||||||
}
|
}
|
||||||
let localAccount = AccountManager.shared.localAccount
|
let localAccount = AccountManager.shared.defaultAccount
|
||||||
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
||||||
|
|
||||||
let tempDirectory = NSTemporaryDirectory()
|
let tempDirectory = NSTemporaryDirectory()
|
||||||
|
@ -376,7 +376,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||||
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
do {
|
do {
|
||||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount)
|
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.defaultAccount)
|
||||||
}
|
}
|
||||||
catch let error as NSError {
|
catch let error as NSError {
|
||||||
NSApplication.shared.presentError(error)
|
NSApplication.shared.presentError(error)
|
||||||
|
@ -401,7 +401,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||||
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let filename = url.lastPathComponent
|
let filename = url.lastPathComponent
|
||||||
let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename)
|
let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.defaultAccount, title: filename)
|
||||||
do {
|
do {
|
||||||
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||||
extension AppDelegate {
|
extension AppDelegate {
|
||||||
|
|
||||||
@IBAction func debugSearch(_ sender: Any?) {
|
@IBAction func debugSearch(_ sender: Any?) {
|
||||||
AccountManager.shared.localAccount.debugRunSearch()
|
AccountManager.shared.defaultAccount.debugRunSearch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
|
||||||
|
|
||||||
let folderTreeControllerDelegate = FolderTreeControllerDelegate()
|
let folderTreeControllerDelegate = FolderTreeControllerDelegate()
|
||||||
|
|
||||||
let rootNode = Node(representedObject: AccountManager.shared.localAccount, parent: nil)
|
let rootNode = Node(representedObject: AccountManager.shared.defaultAccount, parent: nil)
|
||||||
rootNode.canHaveChildNodes = true
|
rootNode.canHaveChildNodes = true
|
||||||
let folderTreeController = TreeController(delegate: folderTreeControllerDelegate, rootNode: rootNode)
|
let folderTreeController = TreeController(delegate: folderTreeControllerDelegate, rootNode: rootNode)
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ private extension SidebarOutlineDataSource {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
guard let parentNode = node.parent else {
|
guard let parentNode = node.parent else {
|
||||||
if let onMyMacAccountNode = treeController.nodeInTreeRepresentingObject(AccountManager.shared.localAccount) {
|
if let onMyMacAccountNode = treeController.nodeInTreeRepresentingObject(AccountManager.shared.defaultAccount) {
|
||||||
return onMyMacAccountNode
|
return onMyMacAccountNode
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -28,7 +28,7 @@ extension NSScriptCommand {
|
||||||
|
|
||||||
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
||||||
let appleEvent = self.appleEvent
|
let appleEvent = self.appleEvent
|
||||||
var account = AccountManager.shared.localAccount
|
var account = AccountManager.shared.defaultAccount
|
||||||
var folder:Folder? = nil
|
var folder:Folder? = nil
|
||||||
if let appleEvent = appleEvent {
|
if let appleEvent = appleEvent {
|
||||||
var descriptorToConsider:NSAppleEventDescriptor?
|
var descriptorToConsider:NSAppleEventDescriptor?
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct DefaultFeedsImporter {
|
||||||
|
|
||||||
appDelegate.logDebugMessage("Importing default feeds.")
|
appDelegate.logDebugMessage("Importing default feeds.")
|
||||||
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
|
let defaultFeedsURL = Bundle.main.url(forResource: "DefaultFeeds", withExtension: "opml")!
|
||||||
try! OPMLImporter.parseAndImport(fileURL: defaultFeedsURL, account: AccountManager.shared.localAccount)
|
try! OPMLImporter.parseAndImport(fileURL: defaultFeedsURL, account: AccountManager.shared.defaultAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func shouldImportDefaultFeeds(_ isFirstRun: Bool) -> Bool {
|
private static func shouldImportDefaultFeeds(_ isFirstRun: Bool) -> Bool {
|
||||||
|
|
|
@ -27,7 +27,7 @@ private extension FolderTreeControllerDelegate {
|
||||||
// Root node is “Top Level” and children are folders. Folders can’t have subfolders.
|
// Root node is “Top Level” and children are folders. Folders can’t have subfolders.
|
||||||
// This will have to be revised later.
|
// This will have to be revised later.
|
||||||
|
|
||||||
guard let folders = AccountManager.shared.localAccount.folders else {
|
guard let folders = AccountManager.shared.defaultAccount.folders else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let folderNodes = folders.map { createNode($0, parent: node) }
|
let folderNodes = folders.map { createNode($0, parent: node) }
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct AddFeedFolderPickerData {
|
||||||
|
|
||||||
let treeControllerDelegate = FolderTreeControllerDelegate()
|
let treeControllerDelegate = FolderTreeControllerDelegate()
|
||||||
|
|
||||||
let rootNode = Node(representedObject: AccountManager.shared.localAccount, parent: nil)
|
let rootNode = Node(representedObject: AccountManager.shared.defaultAccount, parent: nil)
|
||||||
rootNode.canHaveChildNodes = true
|
rootNode.canHaveChildNodes = true
|
||||||
let treeController = TreeController(delegate: treeControllerDelegate, rootNode: rootNode)
|
let treeController = TreeController(delegate: treeControllerDelegate, rootNode: rootNode)
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||||
os_log("Is first run.", log: log, type: .info)
|
os_log("Is first run.", log: log, type: .info)
|
||||||
}
|
}
|
||||||
|
|
||||||
let localAccount = AccountManager.shared.localAccount
|
let localAccount = AccountManager.shared.defaultAccount
|
||||||
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
||||||
|
|
||||||
let tempDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
|
let tempDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
|
||||||
|
|
|
@ -127,7 +127,7 @@ extension SettingsViewController: UIDocumentPickerDelegate {
|
||||||
|
|
||||||
for url in urls {
|
for url in urls {
|
||||||
do {
|
do {
|
||||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount)
|
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.defaultAccount)
|
||||||
} catch {
|
} catch {
|
||||||
presentError(title: "OPML Import Error", message: error.localizedDescription)
|
presentError(title: "OPML Import Error", message: error.localizedDescription)
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ private extension SettingsViewController {
|
||||||
|
|
||||||
let filename = "MySubscriptions.opml"
|
let filename = "MySubscriptions.opml"
|
||||||
let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename)
|
let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename)
|
||||||
let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename)
|
let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.defaultAccount, title: filename)
|
||||||
do {
|
do {
|
||||||
try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8)
|
try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
Loading…
Reference in New Issue