From 39a22deb6a232356bf7b2ef8386679bc8ea2f697 Mon Sep 17 00:00:00 2001 From: vnugent Date: Fri, 10 Nov 2023 22:40:35 -0500 Subject: much needed QOL updates --- lib/admin/src/posts/computedPosts.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/admin/src/posts/computedPosts.ts') diff --git a/lib/admin/src/posts/computedPosts.ts b/lib/admin/src/posts/computedPosts.ts index 44171a5..640226f 100644 --- a/lib/admin/src/posts/computedPosts.ts +++ b/lib/admin/src/posts/computedPosts.ts @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { computed } from "vue"; +import { computed, ref } from "vue"; import { isEqual, find } from 'lodash-es'; import { apiCall } from "@vnuge/vnlib.browser"; import { PostMeta, ComputedPosts, BlogAdminContext } from "../types"; @@ -28,11 +28,12 @@ import { watchAndCompute } from "../helpers"; export const useComputedPosts = (context: BlogAdminContext): ComputedPosts => { //Post api around the post url and channel const postApi = usePostApi(context); + const trigger = ref(0); const { channel, post } = context.getQuery(); //Get all posts - const items = watchAndCompute([channel, post], async () => { + const items = watchAndCompute([channel, post, trigger], async () => { return channel.value ? await apiCall(postApi.getPosts) ?? [] : []; }, []) @@ -40,11 +41,16 @@ export const useComputedPosts = (context: BlogAdminContext): ComputedPosts => { return find(items.value, p => isEqual(p.id, post.value)); }) + const refresh = () => { + trigger.value++; + } + return { ...postApi, items, selectedItem, selectedId:post, - getQuery: context.getQuery + getQuery: context.getQuery, + refresh }; } \ No newline at end of file -- cgit