Swiftgram/submodules/Postbox/Postbox/RenderedPeer.swift
Peter 4459dc5b47 Add 'submodules/Postbox/' from commit '534443c710e63ff4ea595b5dc7be94550c467734'
git-subtree-dir: submodules/Postbox
git-subtree-mainline: 373769682ef152a8d5ef41ccb064a8387b2ca6f0
git-subtree-split: 534443c710e63ff4ea595b5dc7be94550c467734
2019-06-11 18:56:39 +01:00

36 lines
903 B
Swift

import Foundation
public final class RenderedPeer: Equatable {
public let peerId: PeerId
public let peers: SimpleDictionary<PeerId, Peer>
public init(peerId: PeerId, peers: SimpleDictionary<PeerId, Peer>) {
self.peerId = peerId
self.peers = peers
}
public init(peer: Peer) {
self.peerId = peer.id
self.peers = SimpleDictionary([peer.id: peer])
}
public static func ==(lhs: RenderedPeer, rhs: RenderedPeer) -> Bool {
if lhs.peerId != rhs.peerId {
return false
}
if lhs.peers.count != rhs.peers.count {
return false
}
if !lhs.peers.isEqual(other: rhs.peers, with: { p1, p2 in
return p1.isEqual(p2)
}) {
return false
}
return true
}
public var peer: Peer? {
return self.peers[self.peerId]
}
}