[Workaround] Force clear time based attributes for deleted messages

This commit is contained in:
Ali
2021-05-09 00:38:07 +04:00
parent b63dd31c7f
commit 90c2f3742a
2 changed files with 13 additions and 1 deletions

View File

@@ -1096,6 +1096,11 @@ public final class Transaction {
assert(!self.disposed) assert(!self.disposed)
return self.postbox?.searchPeers(query: query) ?? [] return self.postbox?.searchPeers(query: query) ?? []
} }
public func clearTimestampBasedAttribute(id: MessageId, tag: UInt16) {
assert(!self.disposed)
self.postbox?.clearTimestampBasedAttribute(id: id, tag: tag)
}
} }
public enum PostboxResult { public enum PostboxResult {
@@ -3566,6 +3571,10 @@ public final class Postbox {
} }
} }
fileprivate func clearTimestampBasedAttribute(id: MessageId, tag: UInt16) {
self.timestampBasedMessageAttributesTable.remove(tag: tag, id: id, operations: &self.currentTimestampBasedMessageAttributesOperations)
}
fileprivate func reindexUnreadCounters() { fileprivate func reindexUnreadCounters() {
self.groupMessageStatsTable.removeAll() self.groupMessageStatsTable.removeAll()
let _ = CFAbsoluteTimeGetCurrent() let _ = CFAbsoluteTimeGetCurrent()

View File

@@ -65,7 +65,9 @@ func managedAutoremoveMessageOperations(network: Network, postbox: Postbox, isRe
Logger.shared.log("Autoremove", "starting isRemove: \(isRemove)") Logger.shared.log("Autoremove", "starting isRemove: \(isRemove)")
let disposable = combineLatest(timeOffset, postbox.timestampBasedMessageAttributesView(tag: isRemove ? 0 : 1)).start(next: { timeOffset, view in let tag: UInt16 = isRemove ? 0 : 1
let disposable = combineLatest(timeOffset, postbox.timestampBasedMessageAttributesView(tag: tag)).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)
} }
@@ -111,6 +113,7 @@ func managedAutoremoveMessageOperations(network: Network, postbox: Postbox, isRe
}) })
} }
} else { } else {
transaction.clearTimestampBasedAttribute(id: entry.messageId, tag: tag)
Logger.shared.log("Autoremove", "No message to autoremove for \(entry.messageId)") Logger.shared.log("Autoremove", "No message to autoremove for \(entry.messageId)")
} }
}) })