From 4fda17d2c64b2309b0c3b2531f1fafce2542381c Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 27 Jun 2024 18:14:19 +0200 Subject: [PATCH] make siteName optional in api index --- resources/js/composables/useApiIndex.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/js/composables/useApiIndex.js b/resources/js/composables/useApiIndex.js index ffba4997..75b5ca50 100644 --- a/resources/js/composables/useApiIndex.js +++ b/resources/js/composables/useApiIndex.js @@ -2,9 +2,13 @@ import {ref, inject, onBeforeUnmount} from 'vue'; import {router} from '@inertiajs/vue3'; import useQueueEvents from './useQueueEvents.js'; -export function useApiIndex(firstUrl, siteName) { +export function useApiIndex(firstUrl, siteName = null) { const axios = inject('axios'); - const {startListener, stopListener} = useQueueEvents(siteName, () => reload()); + + if (siteName !== null) { + var {startListener, stopListener} = useQueueEvents(siteName, () => reload()); + } + const single = ref(null); const url = ref(firstUrl); @@ -78,8 +82,10 @@ export function useApiIndex(firstUrl, siteName) { url.value = newUrl; } - startListener(); - onBeforeUnmount(() => stopListener()); + if (siteName !== null) { + startListener(); + onBeforeUnmount(() => stopListener()); + } return { data: inner.data,