mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
refactor and cleanup [skip ci]
This commit is contained in:
33
submodules/Postbox/Sources/MutableBasicPeerView.swift
Normal file
33
submodules/Postbox/Sources/MutableBasicPeerView.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
import Foundation
|
||||
|
||||
final class MutableBasicPeerView: MutablePostboxView {
|
||||
private let peerId: PeerId
|
||||
fileprivate var peer: Peer?
|
||||
|
||||
init(postbox: Postbox, peerId: PeerId) {
|
||||
self.peerId = peerId
|
||||
self.peer = postbox.peerTable.get(peerId)
|
||||
}
|
||||
|
||||
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
|
||||
var updated = false
|
||||
if let peer = transaction.currentUpdatedPeers[self.peerId] {
|
||||
self.peer = peer
|
||||
updated = true
|
||||
}
|
||||
|
||||
return updated
|
||||
}
|
||||
|
||||
func immutableView() -> PostboxView {
|
||||
return BasicPeerView(self)
|
||||
}
|
||||
}
|
||||
|
||||
public final class BasicPeerView: PostboxView {
|
||||
public let peer: Peer?
|
||||
|
||||
init(_ view: MutableBasicPeerView) {
|
||||
self.peer = view.peer
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user