mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
chore: rm no longer used useInitialQueries.ts
This commit is contained in:
parent
c786d47a6f
commit
c9eedc4989
1 changed files with 0 additions and 38 deletions
|
@ -1,38 +0,0 @@
|
|||
import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue'
|
||||
import { ref, toValue } from 'vue'
|
||||
|
||||
import type { APIQuery } from '@/api/api'
|
||||
import api from '@/api/api'
|
||||
|
||||
export function useInitialQueries<T extends any[] = any[]>(
|
||||
queries: MaybeRefOrGetter<APIQuery[]> | ComputedRef<APIQuery[]>,
|
||||
{
|
||||
onQueriesResponse,
|
||||
showModal = false,
|
||||
}: {
|
||||
onQueriesResponse?: (...responses: T) => Promise<void> | void
|
||||
showModal?: boolean
|
||||
} = {},
|
||||
) {
|
||||
const loading = ref(true)
|
||||
const responses: Ref<T | null> = ref(null)
|
||||
// FIXME watch `queries` to call on change?
|
||||
|
||||
function call(triggerLoading = true) {
|
||||
if (triggerLoading) loading.value = true
|
||||
return api
|
||||
.fetchAll<T>(toValue(queries), { showModal, initial: true })
|
||||
.then(async (responses_) => {
|
||||
responses.value = responses_
|
||||
if (onQueriesResponse) {
|
||||
await onQueriesResponse(...responses_)
|
||||
}
|
||||
loading.value = false
|
||||
return responses
|
||||
})
|
||||
}
|
||||
|
||||
call()
|
||||
|
||||
return { loading, responses, refetch: call }
|
||||
}
|
Loading…
Add table
Reference in a new issue