diff --git a/Account/Sources/Account/ContainerIdentifier.swift b/Account/Sources/Account/ContainerIdentifier.swift index e7dab9bc1..9c772a87b 100644 --- a/Account/Sources/Account/ContainerIdentifier.swift +++ b/Account/Sources/Account/ContainerIdentifier.swift @@ -14,6 +14,7 @@ public protocol ContainerIdentifiable { } public enum ContainerIdentifier: Hashable, Equatable, Sendable { + case smartFeedController case account(String) // accountID case folder(String, String) // accountID, folderName @@ -55,6 +56,20 @@ public enum ContainerIdentifier: Hashable, Equatable, Sendable { } } + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + + switch self { + case .smartFeedController: + hasher.combine(0) + case .account(let accountID): + hasher.combine(accountID) + case .folder(let accountID, let folderName): + hasher.combine(accountID) + hasher.combine(folderName) + } + } } extension ContainerIdentifier: Encodable { diff --git a/AppKitExtras/Sources/AppKitExtras/Keyboard.swift b/AppKitExtras/Sources/AppKitExtras/Keyboard.swift index 7e10e38bd..535f5a630 100644 --- a/AppKitExtras/Sources/AppKitExtras/Keyboard.swift +++ b/AppKitExtras/Sources/AppKitExtras/Keyboard.swift @@ -17,7 +17,7 @@ public struct KeyboardConstant { public static let spaceKey = " ".keyboardIntegerValue } -public extension String { +extension String { var keyboardIntegerValue: Int? { if isEmpty { @@ -65,6 +65,12 @@ public extension String { } return nil } + + // MARK: - Hashable + + nonisolated public func hash(into hasher: inout Hasher) { + hasher.combine(key) + } } public struct KeyboardKey: Hashable, Sendable { @@ -143,5 +149,12 @@ public struct KeyboardKey: Hashable, Sendable { self.init(integerValue: integerValue, shiftKeyDown: shiftKeyDown, optionKeyDown: optionKeyDown, commandKeyDown: commandKeyDown, controlKeyDown: controlKeyDown) } + + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(integerValue) + } } + #endif diff --git a/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift b/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift index 2745b9724..eb3705406 100644 --- a/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift +++ b/FeedFinder/Sources/FeedFinder/FeedSpecifier.swift @@ -64,6 +64,12 @@ public struct FeedSpecifier: Hashable, Sendable { return currentBestFeed } + + // MARK: - Hashable + + public func hash(into hasher: inout Hasher) { + hasher.combine(urlString) + } } private extension FeedSpecifier { diff --git a/Mac/MainWindow/Sidebar/PasteboardFeed.swift b/Mac/MainWindow/Sidebar/PasteboardFeed.swift index e0fb33621..6bec9956a 100644 --- a/Mac/MainWindow/Sidebar/PasteboardFeed.swift +++ b/Mac/MainWindow/Sidebar/PasteboardFeed.swift @@ -144,6 +144,12 @@ typealias PasteboardFeedDictionary = [String: String] } return d } + + // MARK: - Hashable + + nonisolated func hash(into hasher: inout Hasher) { + hasher.combine(url) + } } extension Feed: PasteboardWriterOwner { diff --git a/Mac/MainWindow/Sidebar/PasteboardFolder.swift b/Mac/MainWindow/Sidebar/PasteboardFolder.swift index 4b110b815..1cafee964 100644 --- a/Mac/MainWindow/Sidebar/PasteboardFolder.swift +++ b/Mac/MainWindow/Sidebar/PasteboardFolder.swift @@ -82,6 +82,12 @@ typealias PasteboardFolderDictionary = [String: String] } return d } + + // MARK: - Hashable + + nonisolated func hash(into hasher: inout Hasher) { + hasher.combine(name) + } } extension Folder: PasteboardWriterOwner { diff --git a/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift b/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift index ececad259..9da99c403 100644 --- a/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift +++ b/Mac/MainWindow/Timeline/Cell/MultilineTextFieldSizer.swift @@ -18,6 +18,11 @@ private struct TextFieldSizerSpecifier: Hashable { let numberOfLines: Int let font: NSFont + + func hash(into hasher: inout Hasher) { + hasher.combine(numberOfLines) + hasher.combine(font.pointSize) + } } struct TextFieldSizeInfo { diff --git a/NewsBlur/Sources/NewsBlur/Models/NewsBlurFeed.swift b/NewsBlur/Sources/NewsBlur/Models/NewsBlurFeed.swift index c210d7a8d..c9c3db020 100644 --- a/NewsBlur/Sources/NewsBlur/Models/NewsBlurFeed.swift +++ b/NewsBlur/Sources/NewsBlur/Models/NewsBlurFeed.swift @@ -18,6 +18,10 @@ public struct NewsBlurFeed: Hashable, Codable, Sendable { public let feedURL: String public let homePageURL: String? public let faviconURL: String? + + public func hash(into hasher: inout Hasher) { + hasher.combine(feedID) + } } public struct NewsBlurFeedsResponse: Decodable, Sendable { @@ -29,6 +33,10 @@ public struct NewsBlurFeedsResponse: Decodable, Sendable { public let name: String public let feedIDs: [Int] + + public func hash(into hasher: inout Hasher) { + hasher.combine(name) + } } } diff --git a/NewsBlur/Sources/NewsBlur/Models/NewsBlurStoryHash.swift b/NewsBlur/Sources/NewsBlur/Models/NewsBlurStoryHash.swift index 2a32ea40e..fe3d46ce1 100644 --- a/NewsBlur/Sources/NewsBlur/Models/NewsBlurStoryHash.swift +++ b/NewsBlur/Sources/NewsBlur/Models/NewsBlurStoryHash.swift @@ -28,6 +28,10 @@ public struct NewsBlurStoryHashesResponse: Decodable, Sendable { self.hash = hash self.timestamp = timestamp } + + public func hash(into hasher: inout Hasher) { + hasher.combine(hash) + } } } diff --git a/Parser/Sources/Parser/Feeds/ParsedAuthor.swift b/Parser/Sources/Parser/Feeds/ParsedAuthor.swift index 022c199e0..7b7d5165e 100644 --- a/Parser/Sources/Parser/Feeds/ParsedAuthor.swift +++ b/Parser/Sources/Parser/Feeds/ParsedAuthor.swift @@ -25,16 +25,16 @@ public struct ParsedAuthor: Hashable, Codable, Sendable { // MARK: - Hashable public func hash(into hasher: inout Hasher) { - if let name = name { + if let name { hasher.combine(name) } - else if let url = url { + else if let url { hasher.combine(url) } - else if let emailAddress = emailAddress { + else if let emailAddress { hasher.combine(emailAddress) } - else if let avatarURL = avatarURL { + else if let avatarURL{ hasher.combine(avatarURL) } else { diff --git a/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift b/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift index 92bf2c135..70f29c647 100644 --- a/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift +++ b/SyncDatabase/Sources/SyncDatabase/SyncStatus.swift @@ -44,4 +44,9 @@ public struct SyncStatus: Hashable, Equatable, Sendable { public func databaseDictionary() -> DatabaseDictionary { return [DatabaseKey.articleID: articleID, DatabaseKey.key: key.rawValue, DatabaseKey.flag: flag, DatabaseKey.selected: selected] } + + public func hash(into hasher: inout Hasher) { + hasher.combine(articleID) + hasher.combine(key) + } } diff --git a/iOS/Timeline/Cell/MultilineUILabelSizer.swift b/iOS/Timeline/Cell/MultilineUILabelSizer.swift index 4764629ff..bd0406fa2 100644 --- a/iOS/Timeline/Cell/MultilineUILabelSizer.swift +++ b/iOS/Timeline/Cell/MultilineUILabelSizer.swift @@ -18,6 +18,11 @@ private struct UILabelSizerSpecifier: Hashable { let numberOfLines: Int let font: UIFont + + func hash(into hasher: inout Hasher) { + hasher.combine(numberOfLines) + hasher.combine(font.pointSize) + } } struct TextFieldSizeInfo {