make siteName optional in api index
This commit is contained in:
parent
094a84c745
commit
4fda17d2c6
|
@ -2,9 +2,13 @@ import {ref, inject, onBeforeUnmount} from 'vue';
|
||||||
import {router} from '@inertiajs/vue3';
|
import {router} from '@inertiajs/vue3';
|
||||||
import useQueueEvents from './useQueueEvents.js';
|
import useQueueEvents from './useQueueEvents.js';
|
||||||
|
|
||||||
export function useApiIndex(firstUrl, siteName) {
|
export function useApiIndex(firstUrl, siteName = null) {
|
||||||
const axios = inject('axios');
|
const axios = inject('axios');
|
||||||
const {startListener, stopListener} = useQueueEvents(siteName, () => reload());
|
|
||||||
|
if (siteName !== null) {
|
||||||
|
var {startListener, stopListener} = useQueueEvents(siteName, () => reload());
|
||||||
|
}
|
||||||
|
|
||||||
const single = ref(null);
|
const single = ref(null);
|
||||||
|
|
||||||
const url = ref(firstUrl);
|
const url = ref(firstUrl);
|
||||||
|
@ -78,8 +82,10 @@ export function useApiIndex(firstUrl, siteName) {
|
||||||
url.value = newUrl;
|
url.value = newUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (siteName !== null) {
|
||||||
startListener();
|
startListener();
|
||||||
onBeforeUnmount(() => stopListener());
|
onBeforeUnmount(() => stopListener());
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: inner.data,
|
data: inner.data,
|
||||||
|
|
Loading…
Reference in New Issue