From 66280a07e607914576b1ae62eff3acf8695c2c0e Mon Sep 17 00:00:00 2001 From: Massedil Date: Mon, 17 Jun 2024 18:12:18 +0200 Subject: [PATCH] post data are correctly restored when editing --- src/views/Posts/EditView.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/Posts/EditView.vue b/src/views/Posts/EditView.vue index db018434c..91564253b 100644 --- a/src/views/Posts/EditView.vue +++ b/src/views/Posts/EditView.vue @@ -195,6 +195,10 @@ onMounted(async () => { pictureFile.value = await buildFileFromIMedia(post.value?.picture); }); +// This is useful when post data is already cached from the API during navigation inside the app +editablePost.value = { ...editablePost.value, ...post.value }; + +// This watch() function is useful when post data loads directly from the API upon page load watch(post, async (newPost: IPost | undefined, oldPost: IPost | undefined) => { if (oldPost?.picture !== newPost?.picture) { pictureFile.value = await buildFileFromIMedia(post.value?.picture);