Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fix deletion issue for topmost quick reply #21

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fix(ui): fix deletion issue for topmost quick reply #21
Osho957 committed Sep 18, 2024
commit 55081803c7b043e682205d17b6f7eefa180c945a
Original file line number Diff line number Diff line change
@@ -50,9 +50,7 @@ const QuickRepliesInput: FC<QuickRepliesInput> = ({
updatedQuickReplies.splice(index, 1);
// Set updated state only if it's greater than minInput
Osho957 marked this conversation as resolved.
Show resolved Hide resolved
setQuickReplies(
updatedQuickReplies.length >= minInput
? updatedQuickReplies
: updatedQuickReplies.length ? updatedQuickReplies : []
updatedQuickReplies
);
};
const updateInput = (index: number) => (p: StdQuickReply) => {
@@ -61,18 +59,10 @@ const QuickRepliesInput: FC<QuickRepliesInput> = ({
};

useEffect(() => {
if (
quickReplies.length === 0 ||
(quickReplies.length === 1 &&
quickReplies[0]?.value?.title?.trim() === "" &&
quickReplies[0]?.value?.payload?.trim() === "")
) {
onChange([]);
} else {

onChange(quickReplies.map(({ value }) => value));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [quickReplies,onChange]);
}, [quickReplies]);

return (
<Box>