Back out of ArticleID struct in Data.framework.
This commit is contained in:
parent
7ce19b0659
commit
f46a3ece48
|
@ -12,7 +12,9 @@ public final class Article: Hashable {
|
||||||
|
|
||||||
weak var account: Account?
|
weak var account: Account?
|
||||||
|
|
||||||
public let articleID: ArticleID
|
public let articleID: String // Unique per database
|
||||||
|
public let feedID: String // Likely a URL, but not necessarily
|
||||||
|
public let uniqueID: String // Unique per feed (RSS guid, for example)
|
||||||
public var title: String?
|
public var title: String?
|
||||||
public var contentHTML: String?
|
public var contentHTML: String?
|
||||||
public var contentText: String?
|
public var contentText: String?
|
||||||
|
@ -33,14 +35,16 @@ public final class Article: Hashable {
|
||||||
|
|
||||||
var feed: Feed? {
|
var feed: Feed? {
|
||||||
get {
|
get {
|
||||||
return account?.existingFeed(with: articleID.feedID)
|
return account?.existingFeed(with: feedID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(account: Account, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: [Author]?, tags: Set<String>?, attachments: [Attachment]?, accountInfo: AccountInfo?) {
|
init(account: Account, articleID: String, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: [Author]?, tags: Set<String>?, attachments: [Attachment]?, accountInfo: AccountInfo?) {
|
||||||
|
|
||||||
self.account = account
|
self.account = account
|
||||||
self.articleID = ArticleID(feedID: feedID, uniqueID: uniqueID)
|
self.articleID = articleID
|
||||||
|
self.feedID = feedID
|
||||||
|
self.uniqueID = uniqueID
|
||||||
self.title = title
|
self.title = title
|
||||||
self.contentHTML = contentHTML
|
self.contentHTML = contentHTML
|
||||||
self.contentText = contentText
|
self.contentText = contentText
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
//
|
|
||||||
// ArticleID.swift
|
|
||||||
// Data
|
|
||||||
//
|
|
||||||
// Created by Brent Simmons on 7/10/17.
|
|
||||||
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
// Any given article’s unique ID is unique only for the feed it appears in.
|
|
||||||
// We can’t rely on feed authors to produce globally unique identifiers.
|
|
||||||
// So ArticleID includes the feedID as well as the uniqueID.
|
|
||||||
//
|
|
||||||
// While we could use a compound primary key in the database (feedID, articleID),
|
|
||||||
// that complicates things more than a bit. So ArticleID.stringValue provides
|
|
||||||
// a single value that can be used as a primary key.
|
|
||||||
|
|
||||||
public struct ArticleID: Hashable {
|
|
||||||
|
|
||||||
public let feedID: String
|
|
||||||
public let uniqueID: String
|
|
||||||
public let stringValue: String // Stored in database
|
|
||||||
public let hashValue: Int
|
|
||||||
|
|
||||||
public init(feedID: String, uniqueID: String) {
|
|
||||||
|
|
||||||
self.feedID = feedID
|
|
||||||
self.uniqueID = uniqueID
|
|
||||||
self.stringValue = "\(feedID) \(uniqueID)"
|
|
||||||
self.hashValue = stringValue.hashValue
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func ==(lhs: ArticleID, rhs: ArticleID) -> Bool {
|
|
||||||
|
|
||||||
return lhs.hashValue == rhs.hashValue && lhs.feedID == rhs.uniqueID && lhs.feedID == rhs.feedID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
843079FA1F0AB57F00B4B7F7 /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844BEEA31F0AB512004AB7CD /* RSCore.framework */; };
|
843079FA1F0AB57F00B4B7F7 /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844BEEA31F0AB512004AB7CD /* RSCore.framework */; };
|
||||||
843A08BA1F148A4400D9C438 /* ArticleID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843A08B91F148A4400D9C438 /* ArticleID.swift */; };
|
|
||||||
844BEE651F0AB3C9004AB7CD /* Data.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844BEE5B1F0AB3C8004AB7CD /* Data.framework */; };
|
844BEE651F0AB3C9004AB7CD /* Data.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844BEE5B1F0AB3C8004AB7CD /* Data.framework */; };
|
||||||
844BEE6A1F0AB3C9004AB7CD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE691F0AB3C9004AB7CD /* DataTests.swift */; };
|
844BEE6A1F0AB3C9004AB7CD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE691F0AB3C9004AB7CD /* DataTests.swift */; };
|
||||||
844BEE791F0AB4B8004AB7CD /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE781F0AB4B8004AB7CD /* Account.swift */; };
|
844BEE791F0AB4B8004AB7CD /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE781F0AB4B8004AB7CD /* Account.swift */; };
|
||||||
|
@ -62,7 +61,6 @@
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
843A08B91F148A4400D9C438 /* ArticleID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleID.swift; sourceTree = "<group>"; };
|
|
||||||
844BEE5B1F0AB3C8004AB7CD /* Data.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Data.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
844BEE5B1F0AB3C8004AB7CD /* Data.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Data.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
844BEE641F0AB3C9004AB7CD /* DataTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DataTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
844BEE641F0AB3C9004AB7CD /* DataTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DataTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
844BEE691F0AB3C9004AB7CD /* DataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTests.swift; sourceTree = "<group>"; };
|
844BEE691F0AB3C9004AB7CD /* DataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTests.swift; sourceTree = "<group>"; };
|
||||||
|
@ -114,7 +112,6 @@
|
||||||
844BEE781F0AB4B8004AB7CD /* Account.swift */,
|
844BEE781F0AB4B8004AB7CD /* Account.swift */,
|
||||||
844BEE7A1F0AB4BE004AB7CD /* Folder.swift */,
|
844BEE7A1F0AB4BE004AB7CD /* Folder.swift */,
|
||||||
844BEE7C1F0AB4C4004AB7CD /* Feed.swift */,
|
844BEE7C1F0AB4C4004AB7CD /* Feed.swift */,
|
||||||
843A08B91F148A4400D9C438 /* ArticleID.swift */,
|
|
||||||
844BEE7E1F0AB4CA004AB7CD /* Article.swift */,
|
844BEE7E1F0AB4CA004AB7CD /* Article.swift */,
|
||||||
844BEE801F0AB4D0004AB7CD /* Author.swift */,
|
844BEE801F0AB4D0004AB7CD /* Author.swift */,
|
||||||
844BEE821F0AB4D6004AB7CD /* Attachment.swift */,
|
844BEE821F0AB4D6004AB7CD /* Attachment.swift */,
|
||||||
|
@ -339,7 +336,6 @@
|
||||||
844BEE9A1F0AB4F8004AB7CD /* DisplayNameProvider.swift in Sources */,
|
844BEE9A1F0AB4F8004AB7CD /* DisplayNameProvider.swift in Sources */,
|
||||||
844BEE8F1F0AB4EF004AB7CD /* Account+OPMLRepresentable.swift in Sources */,
|
844BEE8F1F0AB4EF004AB7CD /* Account+OPMLRepresentable.swift in Sources */,
|
||||||
844BEE991F0AB4F8004AB7CD /* Container.swift in Sources */,
|
844BEE991F0AB4F8004AB7CD /* Container.swift in Sources */,
|
||||||
843A08BA1F148A4400D9C438 /* ArticleID.swift in Sources */,
|
|
||||||
844BEE7B1F0AB4BE004AB7CD /* Folder.swift in Sources */,
|
844BEE7B1F0AB4BE004AB7CD /* Folder.swift in Sources */,
|
||||||
844BEE981F0AB4F8004AB7CD /* AccountDelegate.swift in Sources */,
|
844BEE981F0AB4F8004AB7CD /* AccountDelegate.swift in Sources */,
|
||||||
844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */,
|
844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */,
|
||||||
|
|
Loading…
Reference in New Issue