diff --git a/lib/src/entities/chat.ts b/lib/src/entities/chat.ts
index 0f4764a..c6570ec 100644
--- a/lib/src/entities/chat.ts
+++ b/lib/src/entities/chat.ts
@@ -373,6 +373,9 @@ export class Chat {
if (message.channelId.startsWith(MESSAGE_THREAD_ID_PREFIX)) {
throw "Only one level of thread nesting is allowed"
}
+ if (message.deleted) {
+ throw "You cannot create threads on deleted messages"
+ }
const threadChannelId = this.getThreadId(message.channelId, message.timetoken)
diff --git a/lib/tests/message.test.ts b/lib/tests/message.test.ts
index c28817f..2f15292 100644
--- a/lib/tests/message.test.ts
+++ b/lib/tests/message.test.ts
@@ -208,6 +208,32 @@ describe("Send message test", () => {
expect(logSpy).toHaveBeenCalledWith("This message has not been deleted")
})
+ test("should throw an error if you try to create a thread on a deleted message", async () => {
+ await channel.sendText("Test message")
+ await sleep(150) // history calls have around 130ms of cache time
+
+ const historyBeforeDelete = await channel.getHistory()
+ const messagesBeforeDelete = historyBeforeDelete.messages
+ const sentMessage = messagesBeforeDelete[messagesBeforeDelete.length - 1]
+
+ await sentMessage.delete({ soft: true })
+ await sleep(150) // history calls have around 130ms of cache time
+
+ const historyAfterDelete = await channel.getHistory()
+ const messagesAfterDelete = historyAfterDelete.messages
+
+ const deletedMessage = messagesAfterDelete.find(
+ (message: Message) => message.timetoken === sentMessage.timetoken
+ )
+ let thrownExceptionString = ""
+
+ await deletedMessage.createThread().catch((e) => {
+ thrownExceptionString = e
+ })
+
+ expect(thrownExceptionString).toBe("You cannot create threads on deleted messages")
+ })
+
test("should edit the message", async () => {
await channel.sendText("Test message")
await sleep(150) // history calls have around 130ms of cache time
diff --git a/samples/react-native-group-chat/components/actions-menu/ActionsMenu.tsx b/samples/react-native-group-chat/components/actions-menu/ActionsMenu.tsx
index 046d47f..9e06dc8 100644
--- a/samples/react-native-group-chat/components/actions-menu/ActionsMenu.tsx
+++ b/samples/react-native-group-chat/components/actions-menu/ActionsMenu.tsx
@@ -109,7 +109,7 @@ export function useActionsMenu({
Copy message
- {!removeThreadReply ? (
+ {!removeThreadReply && !currentlyFocusedMessage?.originalPnMessage.deleted ? (
<>