mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
GIF-related fixes part 2
This commit is contained in:
@@ -12,6 +12,7 @@ private enum MetadataPrefix: Int8 {
|
||||
case PeerHistoryInitialized = 9
|
||||
case ShouldReindexUnreadCountsState = 10
|
||||
case TotalUnreadCountStates = 11
|
||||
case PeerHistoryTagInitialized = 12
|
||||
}
|
||||
|
||||
public struct ChatListTotalUnreadCounters: PostboxCoding, Equatable {
|
||||
@@ -51,6 +52,7 @@ final class MessageHistoryMetadataTable: Table {
|
||||
|
||||
private var initializedChatList = Set<InitializedChatListKey>()
|
||||
private var initializedHistoryPeerIds = Set<PeerId>()
|
||||
private var initializedHistoryPeerIdTags: [PeerId: Set<MessageTags>] = [:]
|
||||
private var initializedGroupFeedIndexIds = Set<PeerGroupId>()
|
||||
|
||||
private var peerNextMessageIdByNamespace: [PeerId: [MessageId.Namespace: MessageId.Id]] = [:]
|
||||
@@ -74,6 +76,14 @@ final class MessageHistoryMetadataTable: Table {
|
||||
return self.sharedPeerHistoryInitializedKey
|
||||
}
|
||||
|
||||
private func peerHistoryInitializedTagKey(id: PeerId, tag: UInt32) -> ValueBoxKey {
|
||||
let key = ValueBoxKey(length: 8 + 1 + 4)
|
||||
key.setInt64(0, value: id.toInt64())
|
||||
key.setInt8(8, value: MetadataPrefix.PeerHistoryTagInitialized.rawValue)
|
||||
key.setUInt32(8 + 1, value: tag)
|
||||
return key
|
||||
}
|
||||
|
||||
private func groupFeedIndexInitializedKey(_ id: PeerGroupId) -> ValueBoxKey {
|
||||
self.sharedGroupFeedIndexInitializedKey.setInt32(0, value: id.rawValue)
|
||||
self.sharedGroupFeedIndexInitializedKey.setInt8(4, value: MetadataPrefix.GroupFeedIndexInitialized.rawValue)
|
||||
@@ -201,6 +211,31 @@ final class MessageHistoryMetadataTable: Table {
|
||||
}
|
||||
}
|
||||
|
||||
func setPeerTagInitialized(peerId: PeerId, tag: MessageTags) {
|
||||
if self.initializedHistoryPeerIdTags[peerId] == nil {
|
||||
self.initializedHistoryPeerIdTags[peerId] = Set()
|
||||
}
|
||||
initializedHistoryPeerIdTags[peerId]!.insert(tag)
|
||||
self.sharedBuffer.reset()
|
||||
self.valueBox.set(self.table, key: self.peerHistoryInitializedTagKey(id: peerId, tag: tag.rawValue), value: self.sharedBuffer)
|
||||
}
|
||||
|
||||
func isPeerTagInitialized(peerId: PeerId, tag: MessageTags) -> Bool {
|
||||
if let currentTags = self.initializedHistoryPeerIdTags[peerId], currentTags.contains(tag) {
|
||||
return true
|
||||
} else {
|
||||
if self.valueBox.exists(self.table, key: self.peerHistoryInitializedTagKey(id: peerId, tag: tag.rawValue)) {
|
||||
if self.initializedHistoryPeerIdTags[peerId] == nil {
|
||||
self.initializedHistoryPeerIdTags[peerId] = Set()
|
||||
}
|
||||
initializedHistoryPeerIdTags[peerId]!.insert(tag)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setGroupFeedIndexInitialized(_ groupId: PeerGroupId) {
|
||||
self.initializedGroupFeedIndexIds.insert(groupId)
|
||||
self.sharedBuffer.reset()
|
||||
|
||||
Reference in New Issue
Block a user