Move AccountManager to Account.framework.

This commit is contained in:
Brent Simmons 2017-09-17 12:20:32 -07:00
parent e78fc0d696
commit 121fbf3c27
6 changed files with 23 additions and 21 deletions

View File

@ -20,7 +20,6 @@
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */; };
849A97531ED9EAC0007D329B /* AddFeedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97511ED9EAC0007D329B /* AddFeedController.swift */; };
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */; };
849A975A1ED9EB0D007D329B /* AccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97571ED9EB0D007D329B /* AccountManager.swift */; };
849A975B1ED9EB0D007D329B /* ArticleUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97581ED9EB0D007D329B /* ArticleUtilities.swift */; };
849A975C1ED9EB0D007D329B /* DefaultFeedsImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97591ED9EB0D007D329B /* DefaultFeedsImporter.swift */; };
849A975E1ED9EB72007D329B /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A975D1ED9EB72007D329B /* MainWindowController.swift */; };
@ -383,7 +382,6 @@
849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFolderWindowController.swift; sourceTree = "<group>"; };
849A97511ED9EAC0007D329B /* AddFeedController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedController.swift; path = AddFeed/AddFeedController.swift; sourceTree = "<group>"; };
849A97521ED9EAC0007D329B /* AddFeedWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedWindowController.swift; path = AddFeed/AddFeedWindowController.swift; sourceTree = "<group>"; };
849A97571ED9EB0D007D329B /* AccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = "<group>"; };
849A97581ED9EB0D007D329B /* ArticleUtilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArticleUtilities.swift; sourceTree = "<group>"; };
849A97591ED9EB0D007D329B /* DefaultFeedsImporter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultFeedsImporter.swift; sourceTree = "<group>"; };
849A975D1ED9EB72007D329B /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = "<group>"; };
@ -542,7 +540,6 @@
849A97561ED9EB0D007D329B /* Data */ = {
isa = PBXGroup;
children = (
849A97571ED9EB0D007D329B /* AccountManager.swift */,
849A97581ED9EB0D007D329B /* ArticleUtilities.swift */,
849A97591ED9EB0D007D329B /* DefaultFeedsImporter.swift */,
849A978E1ED9EE72007D329B /* DefaultFeeds.plist */,
@ -1153,7 +1150,6 @@
842E45DD1ED8C54B000A8B52 /* Browser.swift in Sources */,
849A975B1ED9EB0D007D329B /* ArticleUtilities.swift in Sources */,
849A97891ED9ECEF007D329B /* ArticleStyle.swift in Sources */,
849A975A1ED9EB0D007D329B /* AccountManager.swift in Sources */,
849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */,
849A97791ED9EC04007D329B /* TimelineStringUtilities.swift in Sources */,

View File

@ -7,7 +7,7 @@
//
import Foundation
import DataModel
import Data
// These handle multiple accounts.

View File

@ -34,7 +34,8 @@ public final class Account: DisplayNameProvider, Hashable {
var topLevelObjects = [AnyObject]()
var feedIDDictionary = [String: Feed]()
var username: String?
var refreshInProgress = false
static public let accounts = [String: Account]()
init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) {

View File

@ -20,6 +20,7 @@
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419742C1F6DDE84006346C4 /* LocalAccountDelegate.swift */; };
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419742D1F6DDE96006346C4 /* LocalAccountRefresher.swift */; };
846E77521F6EFDFB00A165E2 /* Feed+Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846E77511F6EFDFB00A165E2 /* Feed+Account.swift */; };
846E77541F6F00E300A165E2 /* AccountManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846E77531F6F00E300A165E2 /* AccountManager.swift */; };
848935001F62484F00CEBD24 /* Account.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848934F61F62484F00CEBD24 /* Account.framework */; };
848935051F62485000CEBD24 /* AccountTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848935041F62485000CEBD24 /* AccountTests.swift */; };
/* End PBXBuildFile section */
@ -110,6 +111,7 @@
8419742C1F6DDE84006346C4 /* LocalAccountDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountDelegate.swift; sourceTree = "<group>"; };
8419742D1F6DDE96006346C4 /* LocalAccountRefresher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountRefresher.swift; sourceTree = "<group>"; };
846E77511F6EFDFB00A165E2 /* Feed+Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Feed+Account.swift"; sourceTree = "<group>"; };
846E77531F6F00E300A165E2 /* AccountManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = "<group>"; };
848934F61F62484F00CEBD24 /* Account.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Account.framework; sourceTree = BUILT_PRODUCTS_DIR; };
848934FA1F62484F00CEBD24 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
848934FF1F62484F00CEBD24 /* AccountTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AccountTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@ -211,6 +213,7 @@
848934EC1F62484F00CEBD24 = {
isa = PBXGroup;
children = (
846E77531F6F00E300A165E2 /* AccountManager.swift */,
848935101F62486800CEBD24 /* Account.swift */,
841974241F6DDCE4006346C4 /* AccountDelegate.swift */,
841974001F6DD1EC006346C4 /* Folder.swift */,
@ -441,6 +444,7 @@
846E77451F6EF9B900A165E2 /* Container.swift in Sources */,
8419741A1F6DD583006346C4 /* Account+Container.swift in Sources */,
841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */,
846E77541F6F00E300A165E2 /* AccountManager.swift in Sources */,
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
841974011F6DD1EC006346C4 /* Folder.swift in Sources */,
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */,

View File

@ -8,8 +8,7 @@
import Foundation
import RSCore
import DataModel
import LocalAccount
import Data
let AccountsDidChangeNotification = "AccountsDidChangeNotification"
@ -22,6 +21,7 @@ final class AccountManager: UnreadCountProvider {
private let accountsFolder = RSDataSubfolder(nil, "Accounts")!
private var accountsDictionary = [String: Account]()
let localAccount: Account
var unreadCount = 0 {
didSet {
postUnreadCountDidChangeNotification()
@ -33,6 +33,7 @@ final class AccountManager: UnreadCountProvider {
return Array(accountsDictionary.values)
}
}
var sortedAccounts: [Account] {
get {
return accountsSortedByName()
@ -64,8 +65,8 @@ final class AccountManager: UnreadCountProvider {
}
let localAccountSettingsFile = accountFilePathWithFolder(localAccountFolder)
localAccount = LocalAccount(settingsFile: localAccountSettingsFile, dataFolder: localAccountFolder, identifier: localAccountIdentifier)
accountsDictionary[localAccount.identifier] = localAccount
localAccount = Account(dataFolder: localAccountFolder, settingsFile: localAccountSettingsFile, type: .onMyMac, accountID: localAccountIdentifier)!
accountsDictionary[localAccount.accountID] = localAccount
readNonLocalAccountsFromDisk()
@ -74,22 +75,22 @@ final class AccountManager: UnreadCountProvider {
// MARK: API
func existingAccountWithIdentifier(_ identifier: String) -> Account? {
func existingAccountWithID(_ accountID: String) -> Account? {
return accountsDictionary[identifier]
return accountsDictionary[accountID]
}
func refreshAll() {
accounts.forEach { (oneAccount) in
oneAccount.refreshAll()
accounts.forEach { (account) in
account.refreshAll()
}
}
func anyAccountHasAtLeastOneFeed() -> Bool {
for oneAccount in accounts {
if oneAccount.hasAtLeastOneFeed {
for account in accounts {
if account.hasAtLeastOneFeed() {
return true
}
}
@ -99,8 +100,8 @@ final class AccountManager: UnreadCountProvider {
func anyAccountHasFeedWithURL(_ urlString: String) -> Bool {
for oneAccount in accounts {
if let _ = oneAccount.existingFeedWithURL(urlString) {
for account in accounts {
if let _ = account.existingFeed(withURL: urlString) {
return true
}
}
@ -119,7 +120,7 @@ final class AccountManager: UnreadCountProvider {
// MARK: Notifications
dynamic func unreadCountDidChange(_ notification: Notification) {
@objc dynamic func unreadCountDidChange(_ notification: Notification) {
guard let _ = notification.object as? Account else {
return
@ -161,7 +162,7 @@ final class AccountManager: UnreadCountProvider {
return
}
if let oneAccount = createAccount(oneFilename) {
accountsDictionary[oneAccount.identifier] = oneAccount
accountsDictionary[oneAccount.accountID] = oneAccount
}
}
}

View File

@ -13,7 +13,7 @@ public extension Feed {
var account: Account? {
get {
return Account.existingAccountWithID(accountID)
return AccountManager.sharedInstance.existingAccountWithID(accountID)
}
}
}