mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 03:09:56 +00:00
secret chat bug fixes
This commit is contained in:
parent
33c847b71b
commit
b61e408cd8
@ -708,17 +708,7 @@ public final class Decoder {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
public func decodeInt32ForKey(_ key: String) -> Int32 {
|
||||
if Decoder.positionOnStringKey(self.buffer.memory, offset: &self.offset, maxOffset: self.buffer.length, length: self.buffer.length, key: key, valueType: .Int32) {
|
||||
var value: Int32 = 0
|
||||
memcpy(&value, self.buffer.memory + self.offset, 4)
|
||||
self.offset += 4
|
||||
return value
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func decodeInt32ForKey(_ key: StaticString) -> Int32? {
|
||||
if Decoder.positionOnKey(self.buffer.memory, offset: &self.offset, maxOffset: self.buffer.length, length: self.buffer.length, key: key, valueType: .Int32) {
|
||||
|
||||
@ -37,6 +37,16 @@ final class MutablePeerMergedOperationLogView {
|
||||
self.tailIndex = entry.mergedIndex
|
||||
}
|
||||
}
|
||||
case let .updateContents(entry):
|
||||
if entry.tag == self.tag {
|
||||
loop: for i in 0 ..< self.entries.count {
|
||||
if self.entries[i].tagLocalIndex == entry.tagLocalIndex {
|
||||
self.entries[i] = entry
|
||||
updated = true
|
||||
break loop
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .remove(tag, mergedIndices):
|
||||
if tag == self.tag {
|
||||
updated = true
|
||||
|
||||
@ -3,6 +3,7 @@ import Foundation
|
||||
enum PeerMergedOperationLogOperation {
|
||||
case append(PeerMergedOperationLogEntry)
|
||||
case remove(tag: PeerOperationLogTag, mergedIndices: Set<Int32>)
|
||||
case updateContents(PeerMergedOperationLogEntry)
|
||||
}
|
||||
|
||||
public struct PeerMergedOperationLogEntry {
|
||||
@ -296,9 +297,18 @@ final class PeerOperationLogTable: Table {
|
||||
assert(value.length - value.offset == Int(contentLength))
|
||||
if let contents = Decoder(buffer: MemoryBuffer(memory: value.memory.advanced(by: value.offset), capacity: Int(contentLength), length: Int(contentLength), freeWhenDone: false)).decodeRootObject() {
|
||||
let entryUpdate = f(PeerOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: mergedIndex, contents: contents))
|
||||
switch entryUpdate.mergedIndex {
|
||||
var updatedContents: Coding?
|
||||
switch entryUpdate.contents {
|
||||
case .none:
|
||||
break
|
||||
case let .update(contents):
|
||||
updatedContents = contents
|
||||
}
|
||||
switch entryUpdate.mergedIndex {
|
||||
case .none:
|
||||
if let previousMergedIndex = previousMergedIndex, let updatedContents = updatedContents {
|
||||
operations.append(.updateContents(PeerMergedOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: previousMergedIndex, contents: updatedContents)))
|
||||
}
|
||||
case .remove:
|
||||
if let mergedIndexValue = mergedIndex {
|
||||
mergedIndex = nil
|
||||
@ -312,14 +322,7 @@ final class PeerOperationLogTable: Table {
|
||||
}
|
||||
let updatedMergedIndexValue = self.mergedIndexTable.add(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex)
|
||||
mergedIndex = updatedMergedIndexValue
|
||||
operations.append(.append(PeerMergedOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: updatedMergedIndexValue, contents: contents)))
|
||||
}
|
||||
var updatedContents: Coding?
|
||||
switch entryUpdate.contents {
|
||||
case .none:
|
||||
break
|
||||
case let .update(contents):
|
||||
updatedContents = contents
|
||||
operations.append(.append(PeerMergedOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: updatedMergedIndexValue, contents: updatedContents ?? contents)))
|
||||
}
|
||||
if previousMergedIndex != mergedIndex || updatedContents != nil {
|
||||
let buffer = WriteBuffer()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user