fix: not refetch when reply is deleted

pull/892/head
Ryan Wang 2023-02-28 21:46:02 +08:00
parent f3d5bf7a3f
commit f907102cba
1 changed files with 6 additions and 13 deletions

View File

@ -133,7 +133,11 @@ const {
isLoading,
refetch,
} = useQuery<ListedReply[]>({
queryKey: ["comment-replies", props.comment.comment.metadata.name],
queryKey: [
"comment-replies",
props.comment.comment.metadata.name,
showReplies,
],
queryFn: async () => {
const { data } = await apiClient.reply.listReplies({
commentName: props.comment.comment.metadata.name,
@ -149,20 +153,9 @@ const {
);
return deletingReplies?.length ? 3000 : false;
},
enabled: showReplies.value,
enabled: computed(() => showReplies.value),
});
watch(
() => showReplies.value,
(newValue) => {
if (newValue) {
refetch();
} else {
replies.value = [];
}
}
);
const handleToggleShowReplies = async () => {
showReplies.value = !showReplies.value;
if (showReplies.value) {