Skip to content

Commit

Permalink
Prevent SDK from filtering reacted-to message
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Sep 20, 2024
1 parent c12f806 commit 65dcf33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,13 @@ const ChannelInner = <

const updateMessage = (
updatedMessage: MessageToSend<StreamChatGenerics> | StreamMessage<StreamChatGenerics>,
timestampChanged = true,
) => {
// add the message to the local channel state
channel.state.addMessageSorted(updatedMessage as MessageResponse<StreamChatGenerics>, true);
channel.state.addMessageSorted(
updatedMessage as MessageResponse<StreamChatGenerics>,
timestampChanged,
);

dispatch({
channel,
Expand Down
6 changes: 3 additions & 3 deletions src/components/Message/hooks/useReactionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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 });
}
Expand Down
2 changes: 1 addition & 1 deletion src/context/ChannelActionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export type ChannelActionContextValue<
setQuotedMessage: React.Dispatch<
React.SetStateAction<StreamMessage<StreamChatGenerics> | undefined>
>;
updateMessage: (message: StreamMessage<StreamChatGenerics>) => void;
updateMessage: (message: StreamMessage<StreamChatGenerics>, timestampChanged?: boolean) => void;
};

export const ChannelActionContext = React.createContext<ChannelActionContextValue | undefined>(
Expand Down

0 comments on commit 65dcf33

Please sign in to comment.