another.im-ios/ConversationsClassic/AppData/Client/Client+MartinDisco.swift
2024-08-18 16:43:13 +02:00

25 lines
762 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)
}
}