mirror of https://github.com/halo-dev/halo
fix: unable to expand the replies list of the comment (#4305)
#### What type of PR is this? /area console /kind bug /milestone 2.8.x #### What this PR does / why we need it: 修复评论有新回复时,无法展开回复列表的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/4252 #### Special notes for your reviewer: 需要测试: 1. 选中任意一个评论,尝试进行回复。 2. 点击回复按钮打开回复列表,观察是否能够正常打开。 #### Does this PR introduce a user-facing change? ```release-note 修复 Console 的评论有新回复时,无法展开回复列表的问题。 ```pull/4322/head
parent
57ec43bedc
commit
eced9365a2
|
@ -371,7 +371,6 @@ const handleApproveInBatch = async () => {
|
||||||
<CommentListItem
|
<CommentListItem
|
||||||
:comment="comment"
|
:comment="comment"
|
||||||
:is-selected="checkSelection(comment)"
|
:is-selected="checkSelection(comment)"
|
||||||
@reload="refetch()"
|
|
||||||
>
|
>
|
||||||
<template #checkbox>
|
<template #checkbox>
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -29,7 +29,7 @@ import ReplyListItem from "./ReplyListItem.vue";
|
||||||
import { apiClient } from "@/utils/api-client";
|
import { apiClient } from "@/utils/api-client";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { usePermission } from "@/utils/permission";
|
import { usePermission } from "@/utils/permission";
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { usePluginModuleStore, type PluginModule } from "@/stores/plugin";
|
import { usePluginModuleStore, type PluginModule } from "@/stores/plugin";
|
||||||
import type {
|
import type {
|
||||||
|
@ -39,6 +39,7 @@ import type {
|
||||||
|
|
||||||
const { currentUserHasPermission } = usePermission();
|
const { currentUserHasPermission } = usePermission();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
@ -51,10 +52,6 @@ const props = withDefaults(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(event: "reload"): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const selectedReply = ref<ListedReply>();
|
const selectedReply = ref<ListedReply>();
|
||||||
const hoveredReply = ref<ListedReply>();
|
const hoveredReply = ref<ListedReply>();
|
||||||
const showReplies = ref(false);
|
const showReplies = ref(false);
|
||||||
|
@ -79,7 +76,7 @@ const handleDelete = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to delete comment", error);
|
console.error("Failed to delete comment", error);
|
||||||
} finally {
|
} finally {
|
||||||
emit("reload");
|
queryClient.invalidateQueries({ queryKey: ["comments"] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -136,7 +133,7 @@ const handleApprove = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to approve comment", error);
|
console.error("Failed to approve comment", error);
|
||||||
} finally {
|
} finally {
|
||||||
emit("reload");
|
queryClient.invalidateQueries({ queryKey: ["comments"] });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,7 +177,7 @@ const handleToggleShowReplies = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit("reload");
|
queryClient.invalidateQueries({ queryKey: ["comments"] });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +192,12 @@ const onTriggerReply = (reply: ListedReply) => {
|
||||||
|
|
||||||
const onReplyCreationModalClose = () => {
|
const onReplyCreationModalClose = () => {
|
||||||
selectedReply.value = undefined;
|
selectedReply.value = undefined;
|
||||||
refetch();
|
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["comments"] });
|
||||||
|
|
||||||
|
if (showReplies.value) {
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Subject ref processing
|
// Subject ref processing
|
||||||
|
@ -354,7 +356,7 @@ const subjectRefResult = computed(() => {
|
||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
<VStatusDot
|
<VStatusDot
|
||||||
v-if="comment?.comment?.status?.unreadReplyCount || 0 > 0"
|
v-show="(comment?.comment?.status?.unreadReplyCount || 0) > 0"
|
||||||
v-tooltip="$t('core.comment.list.fields.has_new_replies')"
|
v-tooltip="$t('core.comment.list.fields.has_new_replies')"
|
||||||
state="success"
|
state="success"
|
||||||
animate
|
animate
|
||||||
|
@ -456,7 +458,6 @@ const subjectRefResult = computed(() => {
|
||||||
:class="{ 'hover:bg-white': showReplies }"
|
:class="{ 'hover:bg-white': showReplies }"
|
||||||
:reply="reply"
|
:reply="reply"
|
||||||
:replies="replies"
|
:replies="replies"
|
||||||
@reload="refetch()"
|
|
||||||
@reply="onTriggerReply"
|
@reply="onTriggerReply"
|
||||||
></ReplyListItem>
|
></ReplyListItem>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,8 +16,10 @@ import { apiClient } from "@/utils/api-client";
|
||||||
import { computed, inject, type Ref } from "vue";
|
import { computed, inject, type Ref } from "vue";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { useQueryClient } from "@tanstack/vue-query";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
@ -31,7 +33,6 @@ const props = withDefaults(
|
||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: "reload"): void;
|
|
||||||
(event: "reply", reply: ListedReply): void;
|
(event: "reply", reply: ListedReply): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ const handleDelete = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to delete comment reply", error);
|
console.error("Failed to delete comment reply", error);
|
||||||
} finally {
|
} finally {
|
||||||
emit("reload");
|
queryClient.invalidateQueries({ queryKey: ["comment-replies"] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -85,7 +86,7 @@ const handleApprove = async () => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to approve comment reply", error);
|
console.error("Failed to approve comment reply", error);
|
||||||
} finally {
|
} finally {
|
||||||
emit("reload");
|
queryClient.invalidateQueries({ queryKey: ["comment-replies"] });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue