fmodf
b3b3b3aef7
Reviewed-on: narayana/conversations-classic-ios#1 Co-authored-by: fmodf <fmodf.ios@gmail.com> Co-committed-by: fmodf <fmodf.ios@gmail.com>
24 lines
761 B
Swift
24 lines
761 B
Swift
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)
|
|
}
|
|
}
|