feat: shared loading state + cleanup loading state management (#5835)

* feat: implement shared loading bar component and polished loading states across the app

* feat: align loading states + ensureQueryData changes

* fix: lint + bugs

* fix: skeleton for manage servers page

* fix: merge conflict fix
This commit is contained in:
Calum H.
2026-04-18 19:46:39 +01:00
committed by GitHub
parent 3e32901737
commit 176d4301c3
47 changed files with 2063 additions and 1371 deletions

View File

@@ -0,0 +1,24 @@
import type { DefaultError, UseQueryReturnType } from '@tanstack/vue-query'
import type { Ref } from 'vue'
import { computed } from 'vue'
/** Subset of {@link UseQueryReturnType} passed to {@link useReadyState}. */
export type ReadyStateQuery<TData, TError = DefaultError> = Pick<
UseQueryReturnType<TData, TError>,
'isLoading' | 'data'
>
/**
* Returns true while a query is loading for the FIRST time (no cached data yet).
*
* Excludes background refetches and refetch-on-window-focus by design — those
* have `isLoading === false` once data exists in the cache, so `ReadyTransition`
* stays open and the loading bar stays silent.
*
* Pair with `<ReadyTransition :pending="var which is useReadyState(query)" />`.
*/
export function useReadyState<TData, TError = DefaultError>(
query: ReadyStateQuery<TData, TError>,
): Readonly<Ref<boolean>> {
return computed(() => query.isLoading.value && query.data.value === undefined)
}