Skip to content

Commit

Permalink
[release-2.12] fix: fix the error when saving settings for posts in t…
Browse files Browse the repository at this point in the history
…he uc (#5375)

This is an automated cherry-pick of #5370

/assign LIlGG

```release-note
解决个人中心文章设置时报错的问题
```
  • Loading branch information
halo-dev-bot authored Feb 20, 2024
1 parent e2197b6 commit fe4c240
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions console/uc-src/modules/contents/posts/PostEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ const name = useRouteQuery<string | undefined>("name");
onMounted(async () => {
if (name.value) {
const { data: post } = await apiClient.uc.post.getMyPost({
name: name.value,
});
formState.value = post;
await getLatestPost();
await handleFetchContent();
handleResetCache();
return;
Expand Down Expand Up @@ -189,6 +184,17 @@ useAutoSaveContent(currentCache, toRef(content.value, "raw"), async () => {
}
});
async function getLatestPost() {
if (!name.value) {
return;
}
const { data: latestPost } = await apiClient.uc.post.getMyPost({
name: name.value,
});
formState.value = latestPost;
}
/**
* Fetch content from the head snapshot.
*/
Expand Down Expand Up @@ -372,8 +378,9 @@ const { mutateAsync: handlePublish, isLoading: isPublishing } = useMutation({
// Post setting
const postSettingEditModal = ref(false);
function handleOpenPostSettingEditModal() {
async function handleOpenPostSettingEditModal() {
handleSave({ mute: true });
await getLatestPost();
postSettingEditModal.value = true;
}
Expand Down

0 comments on commit fe4c240

Please sign in to comment.