Swiftgram/Postbox/NoticeEntryView.swift
2018-06-06 14:26:34 +03:00

32 lines
826 B
Swift

import Foundation
final class MutableNoticeEntryView: MutablePostboxView {
private let key: NoticeEntryKey
fileprivate var value: NoticeEntry?
init(postbox: Postbox, key: NoticeEntryKey) {
self.key = key
self.value = postbox.noticeTable.get(key: key)
}
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
if transaction.updatedNoticeEntryKeys.contains(self.key) {
self.value = postbox.noticeTable.get(key: key)
return true
}
return false
}
func immutableView() -> PostboxView {
return NoticeEntryView(self)
}
}
public final class NoticeEntryView: PostboxView {
public let value: NoticeEntry?
init(_ view: MutableNoticeEntryView) {
self.value = view.value
}
}