mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Remove ad animation
This commit is contained in:
@@ -764,6 +764,31 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
let _ = signal.start()
|
||||
}
|
||||
|
||||
func remove(opaqueId: Data) {
|
||||
if var stateValue = self.stateValue {
|
||||
if let index = stateValue.messages.firstIndex(where: { $0.adAttribute?.opaqueId == opaqueId }) {
|
||||
stateValue.messages.remove(at: index)
|
||||
self.stateValue = stateValue
|
||||
}
|
||||
}
|
||||
|
||||
let peerId = self.peerId
|
||||
let _ = (self.account.postbox.transaction { transaction -> Void in
|
||||
let key = ValueBoxKey(length: 8)
|
||||
key.setInt64(0, value: peerId.toInt64())
|
||||
let id = ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedAdMessageStates, key: key)
|
||||
guard var cachedState = transaction.retrieveItemCacheEntry(id: id)?.get(CachedState.self) else {
|
||||
return
|
||||
}
|
||||
if let index = cachedState.messages.firstIndex(where: { $0.opaqueId == opaqueId }) {
|
||||
cachedState.messages.remove(at: index)
|
||||
if let entry = CodableEntry(cachedState) {
|
||||
transaction.putItemCacheEntry(id: id, entry: entry)
|
||||
}
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
|
||||
public class AdMessagesHistoryContext {
|
||||
@@ -803,4 +828,10 @@ public class AdMessagesHistoryContext {
|
||||
impl.markAction(opaqueId: opaqueId)
|
||||
}
|
||||
}
|
||||
|
||||
public func remove(opaqueId: Data) {
|
||||
self.impl.with { impl in
|
||||
impl.remove(opaqueId: opaqueId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user