mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 12:06:58 +01:00
Make FeedlyEntry Hashable, and make some other structs Equatable, so we can put FeedlyEntrys in sets.
This commit is contained in:
parent
5bc255410c
commit
4f04578bd7
@ -8,8 +8,12 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct FeedlyCategory: Decodable, Sendable {
|
||||
public struct FeedlyCategory: Decodable, Sendable, Equatable {
|
||||
|
||||
public let label: String
|
||||
public let id: String
|
||||
|
||||
public static func ==(lhs: FeedlyCategory, rhs: FeedlyCategory) -> Bool {
|
||||
lhs.label == rhs.label && lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct FeedlyEntry: Decodable, Sendable {
|
||||
public struct FeedlyEntry: Decodable, Sendable, Hashable {
|
||||
|
||||
/// the unique, immutable ID for this particular article.
|
||||
public let id: String
|
||||
@ -16,7 +16,7 @@ public struct FeedlyEntry: Decodable, Sendable {
|
||||
/// the article’s title. This string does not contain any HTML markup.
|
||||
public let title: String?
|
||||
|
||||
public struct Content: Decodable, Sendable {
|
||||
public struct Content: Decodable, Sendable, Equatable {
|
||||
|
||||
public enum Direction: String, Decodable, Sendable {
|
||||
case leftToRight = "ltr"
|
||||
@ -25,6 +25,10 @@ public struct FeedlyEntry: Decodable, Sendable {
|
||||
|
||||
public let content: String?
|
||||
public let direction: Direction?
|
||||
|
||||
public static func ==(lhs: Content, rhs: Content) -> Bool {
|
||||
lhs.content == rhs.content && lhs.direction == rhs.direction
|
||||
}
|
||||
}
|
||||
|
||||
/// This object typically has two values: “content” for the content itself, and “direction” (“ltr” for left-to-right, “rtl” for right-to-left). The content itself contains sanitized HTML markup.
|
||||
@ -63,4 +67,13 @@ public struct FeedlyEntry: Decodable, Sendable {
|
||||
|
||||
/// A list of media links (videos, images, sound etc) provided by the feed. Some entries do not have a summary or content, only a collection of media links.
|
||||
public let enclosure: [FeedlyLink]?
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(id)
|
||||
}
|
||||
|
||||
public static func ==(lhs: FeedlyEntry, rhs: FeedlyEntry) -> Bool {
|
||||
|
||||
lhs.id == rhs.id && lhs.title == rhs.title && lhs.content == rhs.content && lhs.summary == rhs.summary && lhs.author == rhs.author && lhs.crawled == rhs.crawled && lhs.recrawled == rhs.recrawled && lhs.origin == rhs.origin && lhs.canonical == rhs.canonical && lhs.alternate == rhs.alternate && lhs.unread == rhs.unread && lhs.tags == rhs.tags && lhs.categories == rhs.categories && lhs.enclosure == rhs.enclosure
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct FeedlyLink: Decodable, Sendable {
|
||||
public struct FeedlyLink: Decodable, Sendable, Equatable {
|
||||
|
||||
public let href: String
|
||||
|
||||
@ -16,4 +16,8 @@ public struct FeedlyLink: Decodable, Sendable {
|
||||
/// When `nil`, it's probably a web page?
|
||||
/// https://groups.google.com/forum/#!searchin/feedly-cloud/feed$20url%7Csort:date/feedly-cloud/Rx3dVd4aTFQ/Hf1ZfLJoCQAJ
|
||||
public let type: String?
|
||||
|
||||
public static func ==(lhs: FeedlyLink, rhs: FeedlyLink) -> Bool {
|
||||
lhs.href == rhs.href && lhs.type == rhs.type
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,14 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct FeedlyOrigin: Decodable, Sendable {
|
||||
public struct FeedlyOrigin: Decodable, Sendable, Equatable {
|
||||
|
||||
public let title: String?
|
||||
public let streamID: String?
|
||||
public let htmlUrl: String?
|
||||
public let htmlURL: String?
|
||||
|
||||
public static func ==(lhs: FeedlyOrigin, rhs: FeedlyOrigin) -> Bool {
|
||||
|
||||
lhs.title == rhs.title && lhs.streamID == rhs.streamID && lhs.htmlURL == rhs.htmlURL
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,12 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct FeedlyTag: Decodable, Sendable {
|
||||
public struct FeedlyTag: Decodable, Sendable, Equatable {
|
||||
|
||||
public let id: String
|
||||
public let label: String?
|
||||
|
||||
public static func ==(lhs: FeedlyTag, rhs: FeedlyTag) -> Bool {
|
||||
lhs.id == rhs.id && lhs.label == rhs.label
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user