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

[release-2.12] fix: fix the error when saving settings for posts in the uc #5375

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading