mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 04:08:07 +00:00
no message
This commit is contained in:
parent
d47a174cd8
commit
1af33ce618
@ -7,10 +7,7 @@ import Postbox
|
||||
import SwiftSignalKit
|
||||
#endif
|
||||
|
||||
public func deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [MessageId]) {
|
||||
for id in ids {
|
||||
if id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
if let message = transaction.getMessage(id) {
|
||||
private func removeMessageMedia(message: Message, mediaBox: MediaBox) {
|
||||
for media in message.media {
|
||||
if let image = media as? TelegramMediaImage {
|
||||
let _ = mediaBox.removeCachedResources(Set(image.representations.map({ WrappedMediaResourceId($0.resource.id) }))).start()
|
||||
@ -19,8 +16,25 @@ public func deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [M
|
||||
let _ = mediaBox.removeCachedResources(Set([WrappedMediaResourceId(file.resource.id)])).start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func deleteMessages(transaction: Transaction, mediaBox: MediaBox, ids: [MessageId]) {
|
||||
for id in ids {
|
||||
if id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
if let message = transaction.getMessage(id) {
|
||||
removeMessageMedia(message: message, mediaBox: mediaBox)
|
||||
}
|
||||
}
|
||||
}
|
||||
transaction.deleteMessages(ids)
|
||||
}
|
||||
|
||||
public func clearHistory(transaction: Transaction, mediaBox: MediaBox, peerId: PeerId) {
|
||||
if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
transaction.withAllMessages(peerId: peerId, { message in
|
||||
removeMessageMedia(message: message, mediaBox: mediaBox)
|
||||
return true
|
||||
})
|
||||
}
|
||||
transaction.clearHistory(peerId)
|
||||
}
|
||||
|
||||
@ -65,16 +65,16 @@ public func clearHistoryInteractively(postbox: Postbox, peerId: PeerId) -> Signa
|
||||
topTimestamp = topIndex.timestamp
|
||||
}
|
||||
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: peerId, explicitTopMessageId: nil)
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId)
|
||||
if let cachedData = transaction.getPeerCachedData(peerId: peerId) as? CachedChannelData, let migrationReference = cachedData.migrationReference {
|
||||
cloudChatAddClearHistoryOperation(transaction: transaction, peerId: migrationReference.maxMessageId.peerId, explicitTopMessageId: MessageId(peerId: migrationReference.maxMessageId.peerId, namespace: migrationReference.maxMessageId.namespace, id: migrationReference.maxMessageId.id + 1))
|
||||
transaction.clearHistory(migrationReference.maxMessageId.peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: migrationReference.maxMessageId.peerId)
|
||||
}
|
||||
if let topTimestamp = topTimestamp {
|
||||
updatePeerChatInclusionWithMinTimestamp(transaction: transaction, id: peerId, minTimestamp: topTimestamp)
|
||||
}
|
||||
} else if peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId)
|
||||
|
||||
if let state = transaction.getPeerChatState(peerId) as? SecretChatState {
|
||||
var layer: SecretChatLayer?
|
||||
|
||||
@ -241,8 +241,11 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
||||
} else {
|
||||
deleteMessages = .complete()
|
||||
}
|
||||
return deleteMessages |> then(deleteUser) |> then(reportSignal) |> then(postbox.transaction { transaction -> Void in
|
||||
transaction.clearHistory(peer.id)
|
||||
return deleteMessages
|
||||
|> then(deleteUser)
|
||||
|> then(reportSignal)
|
||||
|> then(postbox.transaction { transaction -> Void in
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id)
|
||||
})
|
||||
} else if peer.id.namespace == Namespaces.Peer.CloudUser {
|
||||
if let inputPeer = apiInputPeer(peer) {
|
||||
@ -258,8 +261,10 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net
|
||||
} else {
|
||||
reportSignal = .complete()
|
||||
}
|
||||
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId?.id ?? Int32.max - 1, justClear: false) |> then(reportSignal) |> then(postbox.transaction { transaction -> Void in
|
||||
transaction.clearHistory(peer.id)
|
||||
return requestClearHistory(postbox: postbox, network: network, stateManager: stateManager, inputPeer: inputPeer, maxId: operation.topMessageId?.id ?? Int32.max - 1, justClear: false)
|
||||
|> then(reportSignal)
|
||||
|> then(postbox.transaction { transaction -> Void in
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peer.id)
|
||||
})
|
||||
} else {
|
||||
return .complete()
|
||||
|
||||
@ -246,7 +246,7 @@ func processSecretChatIncomingDecryptedOperations(mediaBox: MediaBox, transactio
|
||||
deleteMessages(transaction: transaction, mediaBox: mediaBox, ids: messageIds)
|
||||
}
|
||||
case .clearHistory:
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: mediaBox, peerId: peerId)
|
||||
case let .markMessagesContentAsConsumed(globallyUniqueIds):
|
||||
var messageIds: [MessageId] = []
|
||||
for id in globallyUniqueIds {
|
||||
|
||||
@ -22,17 +22,17 @@ public func removePeerChat(postbox: Postbox, peerId: PeerId, reportChatSpam: Boo
|
||||
}
|
||||
}
|
||||
}
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId)
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .never)
|
||||
transaction.removeOrderedItemListItem(collectionId: Namespaces.OrderedItemList.RecentlySearchedPeerIds, itemId: RecentPeerItemId(peerId).rawValue)
|
||||
} else {
|
||||
cloudChatAddRemoveChatOperation(transaction: transaction, peerId: peerId, reportChatSpam: reportChatSpam)
|
||||
if peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .ifHasMessages)
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId)
|
||||
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .never)
|
||||
transaction.clearHistory(peerId)
|
||||
clearHistory(transaction: transaction, mediaBox: postbox.mediaBox, peerId: peerId)
|
||||
} else {
|
||||
transaction.updatePeerChatListInclusion(peerId, inclusion: .never)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user