Add more logs

This commit is contained in:
Ali
2021-04-28 00:20:34 +04:00
parent 24919025df
commit d3b226af32
3 changed files with 20 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
import Foundation import Foundation
public struct TimestampBasedMessageAttributesEntry { public struct TimestampBasedMessageAttributesEntry: CustomStringConvertible {
public let tag: UInt16 public let tag: UInt16
public let timestamp: Int32 public let timestamp: Int32
public let messageId: MessageId public let messageId: MessageId
@@ -8,6 +8,10 @@ public struct TimestampBasedMessageAttributesEntry {
public var index: MessageIndex { public var index: MessageIndex {
return MessageIndex(id: self.messageId, timestamp: timestamp) return MessageIndex(id: self.messageId, timestamp: timestamp)
} }
public var description: String {
return "(tag: \(self.tag), timestamp: \(self.timestamp), messageId: \(self.messageId))"
}
} }
enum TimestampBasedMessageAttributesOperation { enum TimestampBasedMessageAttributesOperation {
@@ -53,7 +57,11 @@ final class TimestampBasedMessageAttributesTable: Table {
} }
func set(tag: UInt16, id: MessageId, timestamp: Int32, operations: inout [TimestampBasedMessageAttributesOperation]) { func set(tag: UInt16, id: MessageId, timestamp: Int32, operations: inout [TimestampBasedMessageAttributesOperation]) {
if let previousTimestamp = self.indexTable.get(tag: tag, id: id) { let previousTimestamp = self.indexTable.get(tag: tag, id: id)
postboxLog("TimestampBasedMessageAttributesTable set(tag: \(tag), id: \(id), timestamp: \(timestamp)) previousTimestamp: \(String(describing: previousTimestamp))")
if let previousTimestamp = previousTimestamp {
if previousTimestamp == timestamp { if previousTimestamp == timestamp {
return return
} else { } else {
@@ -67,7 +75,11 @@ final class TimestampBasedMessageAttributesTable: Table {
} }
func remove(tag: UInt16, id: MessageId, operations: inout [TimestampBasedMessageAttributesOperation]) { func remove(tag: UInt16, id: MessageId, operations: inout [TimestampBasedMessageAttributesOperation]) {
if let previousTimestamp = self.indexTable.get(tag: tag, id: id) { let previousTimestamp = self.indexTable.get(tag: tag, id: id)
postboxLog("TimestampBasedMessageAttributesTable remove(tag: \(tag), id: \(id)) previousTimestamp: \(String(describing: previousTimestamp))")
if let previousTimestamp = previousTimestamp {
self.valueBox.remove(self.table, key: self.key(tag: tag, timestamp: previousTimestamp, id: id), secure: false) self.valueBox.remove(self.table, key: self.key(tag: tag, timestamp: previousTimestamp, id: id), secure: false)
self.indexTable.remove(tag: tag, id: id) self.indexTable.remove(tag: tag, id: id)
operations.append(.remove(TimestampBasedMessageAttributesEntry(tag: tag, timestamp: previousTimestamp, messageId: id))) operations.append(.remove(TimestampBasedMessageAttributesEntry(tag: tag, timestamp: previousTimestamp, messageId: id)))

View File

@@ -7,6 +7,8 @@ final class MutableTimestampBasedMessageAttributesView {
init(postbox: Postbox, tag: UInt16) { init(postbox: Postbox, tag: UInt16) {
self.tag = tag self.tag = tag
self.head = postbox.timestampBasedMessageAttributesTable.head(tag: tag) self.head = postbox.timestampBasedMessageAttributesTable.head(tag: tag)
postboxLog("MutableTimestampBasedMessageAttributesView: tag: \(tag) head: \(String(describing: self.head))")
} }
func replay(postbox: Postbox, operations: [TimestampBasedMessageAttributesOperation]) -> Bool { func replay(postbox: Postbox, operations: [TimestampBasedMessageAttributesOperation]) -> Bool {

View File

@@ -62,7 +62,9 @@ func managedAutoremoveMessageOperations(network: Network, postbox: Postbox, isRe
|> distinctUntilChanged*/ |> distinctUntilChanged*/
let timeOffset: Signal<Double, NoError> = .single(0.0) let timeOffset: Signal<Double, NoError> = .single(0.0)
Logger.shared.log("Autoremove", "starting isRemove: \(isRemove)")
let disposable = combineLatest(timeOffset, postbox.timestampBasedMessageAttributesView(tag: isRemove ? 0 : 1)).start(next: { timeOffset, view in let disposable = combineLatest(timeOffset, postbox.timestampBasedMessageAttributesView(tag: isRemove ? 0 : 1)).start(next: { timeOffset, view in
let (disposeOperations, beginOperations) = helper.with { helper -> (disposeOperations: [Disposable], beginOperations: [(TimestampBasedMessageAttributesEntry, MetaDisposable)]) in let (disposeOperations, beginOperations) = helper.with { helper -> (disposeOperations: [Disposable], beginOperations: [(TimestampBasedMessageAttributesEntry, MetaDisposable)]) in
return helper.update(view.head) return helper.update(view.head)