From 7e640fb6ac9f0e5266ca9ed81c3ed5a80b31a1d3 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 5 Aug 2021 14:08:13 +1000 Subject: [PATCH] Don't show deleted message in home screen --- .../Sending & Receiving/MessageReceiver+Handling.swift | 7 +++++-- SessionMessagingKit/Threads/TSThread.m | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift index 637bb051f..1b9b36996 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift @@ -228,8 +228,11 @@ extension MessageReceiver { 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 incomingMessage = messageToDelete as? TSIncomingMessage, let notificationIdentifier = incomingMessage.notificationIdentifier, !notificationIdentifier.isEmpty { - SSKEnvironment.shared.notificationsManager!.cancelNotification(notificationIdentifier) + if let incomingMessage = messageToDelete as? TSIncomingMessage { + incomingMessage.markAsReadNow(withSendReadReceipt: false, transaction: transaction) + if let notificationIdentifier = incomingMessage.notificationIdentifier, !notificationIdentifier.isEmpty { + SSKEnvironment.shared.notificationsManager!.cancelNotification(notificationIdentifier) + } } if let serverHash = messageToDelete.serverHash { SnodeAPI.deleteMessage(publicKey: author, serverHashes: [serverHash]).retainUntilComplete() diff --git a/SessionMessagingKit/Threads/TSThread.m b/SessionMessagingKit/Threads/TSThread.m index dd54e43f6..14b16ed09 100644 --- a/SessionMessagingKit/Threads/TSThread.m +++ b/SessionMessagingKit/Threads/TSThread.m @@ -314,6 +314,13 @@ BOOL IsNoteToSelfEnabled(void) if (interaction.isDynamicInteraction) { return NO; } + + if ([interaction isKindOfClass:[TSMessage class]]) { + TSMessage *message = (TSMessage *)interaction; + if (message.isDeleted) { + return NO; + } + } return YES; }