From 65dcf330668899a1f73cc25322605471bb88ec18 Mon Sep 17 00:00:00 2001 From: Anton Arnautov Date: Wed, 18 Sep 2024 23:39:33 +0200 Subject: [PATCH] Prevent SDK from filtering reacted-to message --- src/components/Channel/Channel.tsx | 6 +++++- src/components/Message/hooks/useReactionHandler.ts | 6 +++--- src/context/ChannelActionContext.tsx | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/Channel/Channel.tsx b/src/components/Channel/Channel.tsx index e7c6abbbf..dd925cf2c 100644 --- a/src/components/Channel/Channel.tsx +++ b/src/components/Channel/Channel.tsx @@ -934,9 +934,13 @@ const ChannelInner = < const updateMessage = ( updatedMessage: MessageToSend | StreamMessage, + timestampChanged = true, ) => { // add the message to the local channel state - channel.state.addMessageSorted(updatedMessage as MessageResponse, true); + channel.state.addMessageSorted( + updatedMessage as MessageResponse, + timestampChanged, + ); dispatch({ channel, diff --git a/src/components/Message/hooks/useReactionHandler.ts b/src/components/Message/hooks/useReactionHandler.ts index 271421342..3c9281de6 100644 --- a/src/components/Message/hooks/useReactionHandler.ts +++ b/src/components/Message/hooks/useReactionHandler.ts @@ -93,7 +93,7 @@ export const useReactionHandler = < const tempMessage = createMessagePreview(add, newReaction, message); try { - updateMessage(tempMessage); + updateMessage(tempMessage, false); // @ts-expect-error thread?.upsertReplyLocally({ message: tempMessage }); @@ -102,10 +102,10 @@ export const useReactionHandler = < : await channel.deleteReaction(id, type); // seems useless as we're expecting WS event to come in and replace this anyway - updateMessage(messageResponse.message); + updateMessage(messageResponse.message, false); } catch (error) { // revert to the original message if the API call fails - updateMessage(message); + updateMessage(message, false); // @ts-expect-error thread?.upsertReplyLocally({ message }); } diff --git a/src/context/ChannelActionContext.tsx b/src/context/ChannelActionContext.tsx index 36acea39f..fa4ace23c 100644 --- a/src/context/ChannelActionContext.tsx +++ b/src/context/ChannelActionContext.tsx @@ -95,7 +95,7 @@ export type ChannelActionContextValue< setQuotedMessage: React.Dispatch< React.SetStateAction | undefined> >; - updateMessage: (message: StreamMessage) => void; + updateMessage: (message: StreamMessage, timestampChanged?: boolean) => void; }; export const ChannelActionContext = React.createContext(