minor refactor
This commit is contained in:
parent
31cf0b7b20
commit
2e8e931551
|
@ -226,14 +226,17 @@ extension MessageReceiver {
|
|||
guard message.sender == message.author else { return }
|
||||
let userPublicKey = getUserHexEncodedPublicKey()
|
||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||
if let author = message.author, let timestamp = message.timestamp,
|
||||
let messageToDelete = userPublicKey == message.sender ? TSOutgoingMessage.find(withTimestamp: timestamp) : TSIncomingMessage.find(withAuthorId: author, timestamp: timestamp, transaction: transaction) {
|
||||
if let author = message.author, let timestamp = message.timestamp {
|
||||
let localMessage: TSMessage?
|
||||
if userPublicKey == message.sender { localMessage = TSOutgoingMessage.find(withTimestamp: timestamp) }
|
||||
else { localMessage = TSIncomingMessage.find(withAuthorId: author, timestamp: timestamp, transaction: transaction) }
|
||||
|
||||
if let messageToDelete = localMessage {
|
||||
if let incomingMessage = messageToDelete as? TSIncomingMessage {
|
||||
incomingMessage.markAsReadNow(withSendReadReceipt: false, transaction: transaction)
|
||||
if let notificationIdentifier = incomingMessage.notificationIdentifier, !notificationIdentifier.isEmpty {
|
||||
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [notificationIdentifier])
|
||||
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [notificationIdentifier])
|
||||
|
||||
}
|
||||
}
|
||||
if let serverHash = messageToDelete.serverHash {
|
||||
|
@ -242,6 +245,7 @@ extension MessageReceiver {
|
|||
messageToDelete.updateForDeletion(with: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Visible Messages
|
||||
|
|
Loading…
Reference in New Issue