Continue work on accounts UI in Preferences.
This commit is contained in:
parent
e27a632801
commit
c84f273b92
|
@ -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<Feed>()
|
||||
public var folders: Set<Folder>? = Set<Folder>()
|
||||
|
||||
|
@ -71,6 +72,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
private var _flattenedFeeds = Set<Feed>()
|
||||
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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,3 +8,6 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
final class AccountSettings: Codable {
|
||||
|
||||
}
|
||||
|
|
|
@ -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 = "<group>"; };
|
||||
84EB38101FBA8B9F000D2111 /* KeyboardShortcuts.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = KeyboardShortcuts.html; sourceTree = "<group>"; };
|
||||
84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTableViewBackgroundView.swift; sourceTree = "<group>"; };
|
||||
84F1F0682243455C00DA0616 /* LocalAccount.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalAccount.xib; sourceTree = "<group>"; };
|
||||
84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountPreferencesViewController.swift; sourceTree = "<group>"; };
|
||||
84F204CD1FAACB660076E152 /* FeedListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListViewController.swift; sourceTree = "<group>"; };
|
||||
84F204DF1FAACBB30076E152 /* ArticleArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleArray.swift; sourceTree = "<group>"; };
|
||||
84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PseudoFeed.swift; sourceTree = "<group>"; };
|
||||
|
@ -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 = "<group>";
|
||||
};
|
||||
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 */,
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="LocalAccountPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target"/>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<tabView id="3ki-rg-6yb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="300" height="260"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<tabViewItems>
|
||||
<tabViewItem label="Account Information" identifier="" id="35c-I3-wfs">
|
||||
<view key="view" id="ft2-Mb-5LD">
|
||||
<rect key="frame" x="10" y="33" width="280" height="214"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jiQ-KJ-SS0">
|
||||
<rect key="frame" x="24" y="177" width="38" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Type:" id="tC5-Vt-gBc">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XYX-iz-hnq">
|
||||
<rect key="frame" x="66" y="177" width="73" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="On My Mac" id="6yI-bV-1Sh">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ted-jN-oYR">
|
||||
<rect key="frame" x="18" y="150" width="44" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Name:" id="uyQ-Zi-QCr">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TT0-Kf-YTC">
|
||||
<rect key="frame" x="68" y="147" width="192" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" id="7Vp-Hq-j6n">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xob-U2-rU3">
|
||||
<rect key="frame" x="18" y="73" width="244" height="34"/>
|
||||
<textFieldCell key="cell" selectable="YES" allowsUndo="NO" title="This account stores all of its data on your Mac. It does not sync." id="g7W-if-wP4">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="XYX-iz-hnq" firstAttribute="firstBaseline" secondItem="jiQ-KJ-SS0" secondAttribute="firstBaseline" id="8ew-wx-9n3"/>
|
||||
<constraint firstItem="XYX-iz-hnq" firstAttribute="leading" secondItem="jiQ-KJ-SS0" secondAttribute="trailing" constant="8" symbolic="YES" id="NsF-th-Tqq"/>
|
||||
<constraint firstItem="TT0-Kf-YTC" firstAttribute="leading" secondItem="XYX-iz-hnq" secondAttribute="leading" id="Xqo-JT-9KG"/>
|
||||
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Xob-U2-rU3" secondAttribute="bottom" constant="20" symbolic="YES" id="ZOg-eA-ai2"/>
|
||||
<constraint firstItem="Ted-jN-oYR" firstAttribute="trailing" secondItem="jiQ-KJ-SS0" secondAttribute="trailing" id="aHJ-FN-pUY"/>
|
||||
<constraint firstItem="jiQ-KJ-SS0" firstAttribute="top" secondItem="ft2-Mb-5LD" secondAttribute="top" constant="20" symbolic="YES" id="huT-H6-v8q"/>
|
||||
<constraint firstItem="Xob-U2-rU3" firstAttribute="top" secondItem="TT0-Kf-YTC" secondAttribute="bottom" constant="40" id="hup-vw-QPu"/>
|
||||
<constraint firstItem="Ted-jN-oYR" firstAttribute="leading" secondItem="ft2-Mb-5LD" secondAttribute="leading" constant="20" symbolic="YES" id="oPV-Fn-pvh"/>
|
||||
<constraint firstItem="TT0-Kf-YTC" firstAttribute="top" secondItem="XYX-iz-hnq" secondAttribute="bottom" constant="8" symbolic="YES" id="qSX-zc-QU7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Xob-U2-rU3" secondAttribute="trailing" constant="20" symbolic="YES" id="sbf-Cp-s14"/>
|
||||
<constraint firstItem="Xob-U2-rU3" firstAttribute="leading" secondItem="ft2-Mb-5LD" secondAttribute="leading" constant="20" symbolic="YES" id="uUD-68-qjD"/>
|
||||
<constraint firstAttribute="trailing" secondItem="TT0-Kf-YTC" secondAttribute="trailing" constant="20" symbolic="YES" id="vY4-kF-Q7P"/>
|
||||
<constraint firstItem="TT0-Kf-YTC" firstAttribute="firstBaseline" secondItem="Ted-jN-oYR" secondAttribute="firstBaseline" id="x1e-Qe-Q1g"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</tabViewItem>
|
||||
</tabViewItems>
|
||||
<point key="canvasLocation" x="-333" y="88.5"/>
|
||||
</tabView>
|
||||
</objects>
|
||||
</document>
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue