mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-07 23:58:40 +01:00
Remove last ODB stuff. Feed metadata is now entirely stored in FeedMetadata.plist.
This commit is contained in:
parent
2f1df1dfae
commit
7335c65ecb
@ -70,10 +70,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
var username: String?
|
||||
static let saveQueue = CoalescingQueue(name: "Account Save Queue", interval: 1.0)
|
||||
|
||||
private let settingsODB: ODB
|
||||
private let feedsPath: ODBPath
|
||||
private let feedsTable: ODBTable
|
||||
|
||||
private var unreadCounts = [String: Int]() // [feedID: Int]
|
||||
private let opmlFilePath: String
|
||||
|
||||
@ -147,11 +143,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
self.database = ArticlesDatabase(databaseFilePath: databaseFilePath, accountID: accountID)
|
||||
|
||||
self.feedMetadataPath = (dataFolder as NSString).appendingPathComponent("FeedMetadata.plist")
|
||||
let settingsODBFilePath = (dataFolder as NSString).appendingPathComponent("Settings.odb")
|
||||
self.settingsODB = ODB(filepath: settingsODBFilePath)
|
||||
self.settingsODB.vacuum()
|
||||
self.feedsPath = ODBPath.path(["feeds"])
|
||||
self.feedsTable = settingsODB.ensureTable(self.feedsPath)!
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
@ -609,12 +600,6 @@ extension Account {
|
||||
|
||||
return diskObjects.compactMap { object(with: $0) }
|
||||
}
|
||||
|
||||
func settingsTableForFeed(feedID: String) -> ODBRawValueTable? {
|
||||
let feedPath = feedsPath + feedID
|
||||
let table = settingsODB.ensureTable(feedPath)
|
||||
return table?.rawValueTable
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - FeedMetadataDelegate
|
||||
|
@ -67,11 +67,11 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
||||
|
||||
public var name: String? {
|
||||
get {
|
||||
return settingsTable.string(for: Key.name)
|
||||
return metadata?.name
|
||||
}
|
||||
set {
|
||||
let oldNameForDisplay = nameForDisplay
|
||||
settingsTable.setString(newValue, for: Key.name)
|
||||
metadata?.name = newValue
|
||||
if oldNameForDisplay != nameForDisplay {
|
||||
postDisplayNameDidChangeNotification()
|
||||
}
|
||||
@ -98,7 +98,7 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
||||
public var editedName: String? {
|
||||
// Don’t let editedName == ""
|
||||
get {
|
||||
guard let s = settingsTable.string(for: Key.editedName), !s.isEmpty else {
|
||||
guard let s = metadata?.editedName, !s.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
return s
|
||||
@ -106,10 +106,10 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
||||
set {
|
||||
if newValue != editedName {
|
||||
if let valueToSet = newValue, !valueToSet.isEmpty {
|
||||
settingsTable.setString(valueToSet, for: Key.editedName)
|
||||
metadata?.editedName = valueToSet
|
||||
}
|
||||
else {
|
||||
settingsTable.setString(nil, for: Key.editedName)
|
||||
metadata?.editedName = nil
|
||||
}
|
||||
postDisplayNameDidChangeNotification()
|
||||
}
|
||||
@ -167,7 +167,6 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
||||
}
|
||||
}
|
||||
|
||||
private let settingsTable: ODBRawValueTable
|
||||
private let accountID: String // Used for hashing and equality; account may turn nil
|
||||
|
||||
private var _metadata: FeedMetadata?
|
||||
@ -182,12 +181,10 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha
|
||||
// MARK: - Init
|
||||
|
||||
public init(account: Account, url: String, feedID: String) {
|
||||
|
||||
self.account = account
|
||||
self.accountID = account.accountID
|
||||
self.url = url
|
||||
self.feedID = feedID
|
||||
self.settingsTable = account.settingsTableForFeed(feedID: feedID)!
|
||||
}
|
||||
|
||||
// MARK: - Disk Dictionary
|
||||
|
Loading…
x
Reference in New Issue
Block a user