make siteName optional in api index

This commit is contained in:
philipp lang 2024-06-27 18:14:19 +02:00
parent 094a84c745
commit 4fda17d2c6
1 changed files with 10 additions and 4 deletions

View File

@ -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,