another.im-ios/ConversationsClassic/AppData/Client/Client+MartinDisco.swift
fmodf b3b3b3aef7 mv-experiment (#1)
Reviewed-on: narayana/conversations-classic-ios#1
Co-authored-by: fmodf <fmodf.ios@gmail.com>
Co-committed-by: fmodf <fmodf.ios@gmail.com>
2024-09-03 15:13:58 +00:00

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)
}
}