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:
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
|
||||
final class MutableSynchronizeGroupMessageStatsView: MutablePostboxView {
|
||||
fileprivate var groupsAndNamespaces: Set<PeerGroupAndNamespace>
|
||||
|
||||
init(postbox: Postbox) {
|
||||
self.groupsAndNamespaces = postbox.synchronizeGroupMessageStatsTable.get()
|
||||
}
|
||||
|
||||
func replay(postbox: Postbox, transaction: PostboxTransaction) -> Bool {
|
||||
var updated = false
|
||||
if !transaction.currentUpdatedGroupSummarySynchronizeOperations.isEmpty {
|
||||
for (groupIdAndNamespace, value) in transaction.currentUpdatedGroupSummarySynchronizeOperations {
|
||||
if value {
|
||||
if !self.groupsAndNamespaces.contains(groupIdAndNamespace) {
|
||||
self.groupsAndNamespaces.insert(groupIdAndNamespace)
|
||||
updated = true
|
||||
}
|
||||
} else {
|
||||
if self.groupsAndNamespaces.contains(groupIdAndNamespace) {
|
||||
self.groupsAndNamespaces.remove(groupIdAndNamespace)
|
||||
updated = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return updated
|
||||
}
|
||||
|
||||
func immutableView() -> PostboxView {
|
||||
return SynchronizeGroupMessageStatsView(self)
|
||||
}
|
||||
}
|
||||
|
||||
public final class SynchronizeGroupMessageStatsView: PostboxView {
|
||||
public let groupsAndNamespaces: Set<PeerGroupAndNamespace>
|
||||
|
||||
init(_ view: MutableSynchronizeGroupMessageStatsView) {
|
||||
self.groupsAndNamespaces = view.groupsAndNamespaces
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user