Avoid setting duplicate breadcrumbs

This commit is contained in:
Shadowfacts 2023-05-28 21:54:31 -07:00
parent ef00c0e2df
commit 2b5b749dc8
2 changed files with 10 additions and 2 deletions

View File

@ -8,11 +8,11 @@
import Foundation import Foundation
public struct NodeInfo: Decodable, Sendable { public struct NodeInfo: Decodable, Sendable, Equatable {
public let version: String public let version: String
public let software: Software public let software: Software
public struct Software: Decodable, Sendable { public struct Software: Decodable, Sendable, Equatable {
public let name: String public let name: String
public let version: String public let version: String
} }

View File

@ -89,6 +89,14 @@ class MastodonController: ObservableObject {
.combineLatest($nodeInfo) .combineLatest($nodeInfo)
.sink { [unowned self] (instance, nodeInfo) in .sink { [unowned self] (instance, nodeInfo) in
self.instanceFeatures.update(instance: instance, nodeInfo: nodeInfo) self.instanceFeatures.update(instance: instance, nodeInfo: nodeInfo)
}
.store(in: &cancellables)
$instanceInfo
.compactMap { $0 }
.removeDuplicates(by: { $0.version == $1.version })
.combineLatest($nodeInfo.removeDuplicates())
.sink { (instance, nodeInfo) in
setInstanceBreadcrumb(instance: instance, nodeInfo: nodeInfo) setInstanceBreadcrumb(instance: instance, nodeInfo: nodeInfo)
} }
.store(in: &cancellables) .store(in: &cancellables)