mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-18 12:28:37 +01:00
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 static let shared = AccountManager()
|
||||
public let localAccount: Account
|
||||
public let defaultAccount: Account
|
||||
private let accountsFolder = RSDataSubfolder(nil, "Accounts")!
|
||||
private var accountsDictionary = [String: Account]()
|
||||
|
||||
@ -74,8 +74,8 @@ public final class AccountManager: UnreadCountProvider {
|
||||
abort()
|
||||
}
|
||||
|
||||
localAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
|
||||
accountsDictionary[localAccount.accountID] = localAccount
|
||||
defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
|
||||
accountsDictionary[defaultAccount.accountID] = defaultAccount
|
||||
|
||||
readNonLocalAccountsFromDisk()
|
||||
|
||||
@ -179,10 +179,10 @@ public final class AccountManager: UnreadCountProvider {
|
||||
|
||||
return accounts.sorted { (account1, account2) -> Bool in
|
||||
|
||||
if account1 === localAccount {
|
||||
if account1 === defaultAccount {
|
||||
return true
|
||||
}
|
||||
if account2 === localAccount {
|
||||
if account2 === defaultAccount {
|
||||
return false
|
||||
}
|
||||
return (account1.nameForDisplay as NSString).localizedStandardCompare(account2.nameForDisplay) == .orderedAscending
|
||||
|
@ -117,7 +117,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
if isFirstRun {
|
||||
logDebugMessage("Is first run.")
|
||||
}
|
||||
let localAccount = AccountManager.shared.localAccount
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
||||
|
||||
let tempDirectory = NSTemporaryDirectory()
|
||||
@ -376,7 +376,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount)
|
||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.defaultAccount)
|
||||
}
|
||||
catch let error as NSError {
|
||||
NSApplication.shared.presentError(error)
|
||||
@ -401,7 +401,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
if result == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||
DispatchQueue.main.async {
|
||||
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 {
|
||||
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
||||
}
|
||||
@ -506,7 +506,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
extension AppDelegate {
|
||||
|
||||
@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 rootNode = Node(representedObject: AccountManager.shared.localAccount, parent: nil)
|
||||
let rootNode = Node(representedObject: AccountManager.shared.defaultAccount, parent: nil)
|
||||
rootNode.canHaveChildNodes = true
|
||||
let folderTreeController = TreeController(delegate: folderTreeControllerDelegate, rootNode: rootNode)
|
||||
|
||||
|
@ -281,7 +281,7 @@ private extension SidebarOutlineDataSource {
|
||||
return node
|
||||
}
|
||||
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 nil
|
||||
|
@ -28,7 +28,7 @@ extension NSScriptCommand {
|
||||
|
||||
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
||||
let appleEvent = self.appleEvent
|
||||
var account = AccountManager.shared.localAccount
|
||||
var account = AccountManager.shared.defaultAccount
|
||||
var folder:Folder? = nil
|
||||
if let appleEvent = appleEvent {
|
||||
var descriptorToConsider:NSAppleEventDescriptor?
|
||||
|
@ -19,7 +19,7 @@ struct DefaultFeedsImporter {
|
||||
|
||||
appDelegate.logDebugMessage("Importing default feeds.")
|
||||
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 {
|
||||
|
@ -27,7 +27,7 @@ private extension FolderTreeControllerDelegate {
|
||||
// Root node is “Top Level” and children are folders. Folders can’t have subfolders.
|
||||
// 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
|
||||
}
|
||||
let folderNodes = folders.map { createNode($0, parent: node) }
|
||||
|
@ -21,7 +21,7 @@ struct AddFeedFolderPickerData {
|
||||
|
||||
let treeControllerDelegate = FolderTreeControllerDelegate()
|
||||
|
||||
let rootNode = Node(representedObject: AccountManager.shared.localAccount, parent: nil)
|
||||
let rootNode = Node(representedObject: AccountManager.shared.defaultAccount, parent: nil)
|
||||
rootNode.canHaveChildNodes = true
|
||||
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)
|
||||
}
|
||||
|
||||
let localAccount = AccountManager.shared.localAccount
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
DefaultFeedsImporter.importIfNeeded(isFirstRun, account: localAccount)
|
||||
|
||||
let tempDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
|
||||
|
@ -127,7 +127,7 @@ extension SettingsViewController: UIDocumentPickerDelegate {
|
||||
|
||||
for url in urls {
|
||||
do {
|
||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount)
|
||||
try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.defaultAccount)
|
||||
} catch {
|
||||
presentError(title: "OPML Import Error", message: error.localizedDescription)
|
||||
}
|
||||
@ -174,7 +174,7 @@ private extension SettingsViewController {
|
||||
|
||||
let filename = "MySubscriptions.opml"
|
||||
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 {
|
||||
try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8)
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user