Swiftgram/Postbox/PeerGroupStateView.swift
Peter Iakovlev 59e1f10908 no message
2018-02-06 22:31:32 +04:00

36 lines
958 B
Swift

import Foundation
final class MutablePeerGroupStateView: MutablePostboxView {
let groupId: PeerGroupId
var state: PeerGroupState?
init(postbox: Postbox, groupId: PeerGroupId) {
self.groupId = groupId
self.state = postbox.peerGroupStateTable.get(groupId)
}
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
if transaction.currentUpdatedPeerGroupStates.contains(self.groupId) {
self.state = postbox.peerGroupStateTable.get(self.groupId)
return true
} else {
return false
}
}
func immutableView() -> PostboxView {
return PeerGroupStateView(self)
}
}
public final class PeerGroupStateView: PostboxView {
public let groupId: PeerGroupId
public let state: PeerGroupState?
init(_ view: MutablePeerGroupStateView) {
self.groupId = view.groupId
self.state = view.state
}
}