another.im-ios/ConversationsClassic/AppData/Client/Client+MartinDisco.swift

24 lines
761 B
Swift
Raw Normal View History

2024-08-18 14:43:13 +00:00
import Combine
import Foundation
import GRDB
import Martin
final class ClientMartinDiscoManager {
private(set) var features: [ServerFeature] = []
private var cancellables: Set<AnyCancellable> = []
init(_ xmppConnection: XMPPClient) {
// subscribe to client server features
xmppConnection.module(DiscoveryModule.self).$serverDiscoResult
.sink { [weak self] disco in
let allFeatures = ServerFeature.allFeatures
let features = disco.features
.compactMap { featureId in
allFeatures.first(where: { $0.xmppId == featureId })
}
self?.features = features
}
.store(in: &cancellables)
}
}