import Foundation #if os(macOS) import PostboxMac import SwiftSignalKitMac #else import Postbox import SwiftSignalKit #endif public func joinChannel(account: Account, peerId: PeerId) -> Signal { return account.postbox.loadedPeerWithId(peerId) |> take(1) |> mapToSignal { peer -> Signal in if let inputChannel = apiInputChannel(peer) { return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel)) |> retryRequest |> mapToSignal { updates -> Signal in account.stateManager.addUpdates(updates) return .complete() } } else { return .complete() } } }