diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index d5652a013..d11b5c88b 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -45,6 +45,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, public let accountID: String public let type: AccountType public var nameForDisplay = "" + public var name = "" public var topLevelFeeds = Set() public var folders: Set? = Set() @@ -71,6 +72,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, private var _flattenedFeeds = Set() private var flattenedFeedsNeedUpdate = true + private let settingsPath: String + private var settings = AccountSettings() + private let feedMetadataPath: String private typealias FeedMetadataDictionary = [String: FeedMetadata] private var feedMetadata = FeedMetadataDictionary() @@ -134,6 +138,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, self.database = ArticlesDatabase(databaseFilePath: databaseFilePath, accountID: accountID) self.feedMetadataPath = (dataFolder as NSString).appendingPathComponent("FeedMetadata.plist") + self.settingsPath = (dataFolder as NSString).appendingPathComponent("Settings.plist") NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) @@ -582,22 +587,25 @@ extension Account: FeedMetadataDelegate { private extension Account { - struct Key { - static let children = "children" - static let userInfo = "userInfo" - static let unreadCount = "unreadCount" - } - func queueSaveToDiskIfNeeded() { - Account.saveQueue.add(self, #selector(saveToDiskIfNeeded)) } func pullObjectsFromDisk() { + importSettings() importFeedMetadata() importOPMLFile(path: opmlFilePath) } + func importSettings() { + let url = URL(fileURLWithPath: settingsPath) + guard let data = try? Data(contentsOf: url) else { + return + } + let decoder = PropertyListDecoder() + settings = (try? decoder.decode(AccountSettings.self, from: data)) ?? AccountSettings() + } + func importFeedMetadata() { let url = URL(fileURLWithPath: feedMetadataPath) guard let data = try? Data(contentsOf: url) else { diff --git a/Frameworks/Account/Account.xcodeproj/project.pbxproj b/Frameworks/Account/Account.xcodeproj/project.pbxproj index 94d50d5c0..1fcc0efdb 100644 --- a/Frameworks/Account/Account.xcodeproj/project.pbxproj +++ b/Frameworks/Account/Account.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 84D09623217418DC00D77525 /* FeedbinTagging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D09622217418DC00D77525 /* FeedbinTagging.swift */; }; 84D0962521741B8500D77525 /* FeedbinSavedSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D0962421741B8500D77525 /* FeedbinSavedSearch.swift */; }; 84EAC4822148CC6300F154AB /* RSDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84EAC4812148CC6300F154AB /* RSDatabase.framework */; }; + 84F1F06E2243524700DA0616 /* AccountSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AF4EA3222CFDD100F6A800 /* AccountSettings.swift */; }; 84F73CF1202788D90000BCEF /* ArticleFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F73CF0202788D80000BCEF /* ArticleFetcher.swift */; }; /* End PBXBuildFile section */ @@ -431,6 +432,7 @@ 841974011F6DD1EC006346C4 /* Folder.swift in Sources */, 846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */, 844B297F210CE37E004020B3 /* UnreadCountProvider.swift in Sources */, + 84F1F06E2243524700DA0616 /* AccountSettings.swift in Sources */, 84245C851FDDD8CB0074AFBB /* FeedbinFeed.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Frameworks/Account/AccountSettings.swift b/Frameworks/Account/AccountSettings.swift index aa138a84b..25db6f618 100644 --- a/Frameworks/Account/AccountSettings.swift +++ b/Frameworks/Account/AccountSettings.swift @@ -8,3 +8,6 @@ import Foundation +final class AccountSettings: Codable { + +} diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 0e6cbdaae..128ba7644 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -314,6 +314,10 @@ 84EB381F1FBA8B9F000D2111 /* KeyboardShortcuts.html in Resources */ = {isa = PBXBuildFile; fileRef = 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */; }; 84F1F0562242038B00DA0616 /* AccountsTableViewBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */; }; 84F1F0572242038B00DA0616 /* AccountsTableViewBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */; }; + 84F1F0692243455C00DA0616 /* LocalAccount.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84F1F0682243455C00DA0616 /* LocalAccount.xib */; }; + 84F1F06A2243455C00DA0616 /* LocalAccount.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84F1F0682243455C00DA0616 /* LocalAccount.xib */; }; + 84F1F06C2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */; }; + 84F1F06D2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */; }; 84F204E01FAACBB30076E152 /* ArticleArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DF1FAACBB30076E152 /* ArticleArray.swift */; }; 84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */; }; 84F2D5381FC22FCC00998D64 /* TodayFeedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2D5361FC22FCB00998D64 /* TodayFeedDelegate.swift */; }; @@ -917,6 +921,8 @@ 84E95D231FB1087500552D99 /* ArticlePasteboardWriter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticlePasteboardWriter.swift; sourceTree = ""; }; 84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = KeyboardShortcuts.html; sourceTree = ""; }; 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTableViewBackgroundView.swift; sourceTree = ""; }; + 84F1F0682243455C00DA0616 /* LocalAccount.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalAccount.xib; sourceTree = ""; }; + 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountPreferencesViewController.swift; sourceTree = ""; }; 84F204CD1FAACB660076E152 /* FeedListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListViewController.swift; sourceTree = ""; }; 84F204DF1FAACBB30076E152 /* ArticleArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleArray.swift; sourceTree = ""; }; 84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PseudoFeed.swift; sourceTree = ""; }; @@ -1135,6 +1141,7 @@ 842AE5B82241F37B004A742C /* AccountsPreferencesViewController.swift */, 842AE5B72241F37B004A742C /* AccountsControlsBackgroundView.swift */, 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */, + 84F1F0672243455C00DA0616 /* Local */, ); name = Accounts; path = NetNewsWire/Preferences/Accounts; @@ -1656,6 +1663,15 @@ path = NetNewsWire/Resources/KeyboardShortcuts; sourceTree = SOURCE_ROOT; }; + 84F1F0672243455C00DA0616 /* Local */ = { + isa = PBXGroup; + children = ( + 84F1F0682243455C00DA0616 /* LocalAccount.xib */, + 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */, + ); + path = Local; + sourceTree = ""; + }; 84F2D5341FC22FCB00998D64 /* SmartFeeds */ = { isa = PBXGroup; children = ( @@ -2267,6 +2283,7 @@ 8405DDA322168920008CE1BF /* TimelineTableView.xib in Resources */, 840F7C9B21BDA4B40057E851 /* TimelineKeyboardShortcuts.plist in Resources */, 840F7C9C21BDA4B40057E851 /* template.html in Resources */, + 84F1F06A2243455C00DA0616 /* LocalAccount.xib in Resources */, 840F7C9D21BDA4B40057E851 /* AddFeedSheet.xib in Resources */, 840F7C9E21BDA4B40057E851 /* DB5.plist in Resources */, 840F7C9F21BDA4B40057E851 /* SidebarKeyboardShortcuts.plist in Resources */, @@ -2306,6 +2323,7 @@ 849A979D1ED9EFEB007D329B /* template.html in Resources */, 849A97A91ED9F9AA007D329B /* AddFeedSheet.xib in Resources */, 842E45E71ED8C747000A8B52 /* DB5.plist in Resources */, + 84F1F0692243455C00DA0616 /* LocalAccount.xib in Resources */, 844B5B691FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist in Resources */, 84A3EE5F223B667F00557320 /* DefaultFeeds.opml in Resources */, 849A97AC1ED9F9BC007D329B /* AddFolderSheet.xib in Resources */, @@ -2482,6 +2500,7 @@ 840F7C5221BDA4B40057E851 /* FeedInspectorViewController.swift in Sources */, 840F7C5321BDA4B40057E851 /* FolderPasteboardWriter.swift in Sources */, 840F7C5421BDA4B40057E851 /* SidebarOutlineDataSource.swift in Sources */, + 84F1F06D2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */, 840F7C5521BDA4B40057E851 /* SidebarCellAppearance.swift in Sources */, 840F7C5621BDA4B40057E851 /* FeedFinder.swift in Sources */, 840F7C5721BDA4B40057E851 /* StarredFeedDelegate.swift in Sources */, @@ -2603,6 +2622,7 @@ 84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */, D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */, 849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */, + 84F1F06C2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */, 8405DD8A2213E0E3008CE1BF /* DetailContainerView.swift in Sources */, 519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */, 84E8E0DB202EC49300562D8F /* TimelineViewController+ContextualMenus.swift in Sources */, diff --git a/NetNewsWire/Preferences/Accounts/Local/LocalAccount.xib b/NetNewsWire/Preferences/Accounts/Local/LocalAccount.xib new file mode 100644 index 000000000..f4dea2b98 --- /dev/null +++ b/NetNewsWire/Preferences/Accounts/Local/LocalAccount.xib @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NetNewsWire/Preferences/Accounts/Local/LocalAccountPreferencesViewController.swift b/NetNewsWire/Preferences/Accounts/Local/LocalAccountPreferencesViewController.swift new file mode 100644 index 000000000..1e9dd955b --- /dev/null +++ b/NetNewsWire/Preferences/Accounts/Local/LocalAccountPreferencesViewController.swift @@ -0,0 +1,24 @@ +// +// LocalAccountPreferencesViewController.swift +// NetNewsWire +// +// Created by Brent Simmons on 3/20/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import AppKit +import Account + +final class LocalAccountPreferencesViewController: NSViewController { + + private weak var account: Account? + + init(account: Account) { + super.init(nibName: "LocalAccount", bundle: nil) + self.account = account + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + } +}