mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
secret chat bug fixes
This commit is contained in:
parent
33c847b71b
commit
b61e408cd8
@ -709,16 +709,6 @@ public final class Decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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? {
|
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) {
|
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
|
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):
|
case let .remove(tag, mergedIndices):
|
||||||
if tag == self.tag {
|
if tag == self.tag {
|
||||||
updated = true
|
updated = true
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import Foundation
|
|||||||
enum PeerMergedOperationLogOperation {
|
enum PeerMergedOperationLogOperation {
|
||||||
case append(PeerMergedOperationLogEntry)
|
case append(PeerMergedOperationLogEntry)
|
||||||
case remove(tag: PeerOperationLogTag, mergedIndices: Set<Int32>)
|
case remove(tag: PeerOperationLogTag, mergedIndices: Set<Int32>)
|
||||||
|
case updateContents(PeerMergedOperationLogEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PeerMergedOperationLogEntry {
|
public struct PeerMergedOperationLogEntry {
|
||||||
@ -296,9 +297,18 @@ final class PeerOperationLogTable: Table {
|
|||||||
assert(value.length - value.offset == Int(contentLength))
|
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() {
|
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))
|
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:
|
case .none:
|
||||||
break
|
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:
|
case .remove:
|
||||||
if let mergedIndexValue = mergedIndex {
|
if let mergedIndexValue = mergedIndex {
|
||||||
mergedIndex = nil
|
mergedIndex = nil
|
||||||
@ -312,14 +322,7 @@ final class PeerOperationLogTable: Table {
|
|||||||
}
|
}
|
||||||
let updatedMergedIndexValue = self.mergedIndexTable.add(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex)
|
let updatedMergedIndexValue = self.mergedIndexTable.add(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex)
|
||||||
mergedIndex = updatedMergedIndexValue
|
mergedIndex = updatedMergedIndexValue
|
||||||
operations.append(.append(PeerMergedOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: updatedMergedIndexValue, contents: contents)))
|
operations.append(.append(PeerMergedOperationLogEntry(peerId: peerId, tag: tag, tagLocalIndex: tagLocalIndex, mergedIndex: updatedMergedIndexValue, contents: updatedContents ?? contents)))
|
||||||
}
|
|
||||||
var updatedContents: Coding?
|
|
||||||
switch entryUpdate.contents {
|
|
||||||
case .none:
|
|
||||||
break
|
|
||||||
case let .update(contents):
|
|
||||||
updatedContents = contents
|
|
||||||
}
|
}
|
||||||
if previousMergedIndex != mergedIndex || updatedContents != nil {
|
if previousMergedIndex != mergedIndex || updatedContents != nil {
|
||||||
let buffer = WriteBuffer()
|
let buffer = WriteBuffer()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user