diff options
author | vnugent <public@vaughnnugent.com> | 2023-11-10 22:40:35 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-11-10 22:40:35 -0500 |
commit | 39a22deb6a232356bf7b2ef8386679bc8ea2f697 (patch) | |
tree | 743eb0a0bb06a8ae85a36778c748880374798f01 /lib/admin/src/posts/computedPosts.ts | |
parent | 00582bef545a912c2f81ea359dc00c92dd991ceb (diff) |
much needed QOL updates
Diffstat (limited to 'lib/admin/src/posts/computedPosts.ts')
-rw-r--r-- | lib/admin/src/posts/computedPosts.ts | 12 |
1 files changed, 9 insertions, 3 deletions
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 <https://www.gnu.org/licenses/>. -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 |