Use loading instead of validating to avoid flicker
This commit is contained in:
@ -32,9 +32,9 @@ type LibraryFilterMenuProps = {
|
||||
}
|
||||
|
||||
export function LibraryFilterMenu(props: LibraryFilterMenuProps): JSX.Element {
|
||||
const { labels, isValidating: labelsLoading } = useGetLabelsQuery()
|
||||
const { labels, isLoading: labelsLoading } = useGetLabelsQuery()
|
||||
const { savedSearches, isLoading: searchesLoading } = useGetSavedSearchQuery()
|
||||
const { subscriptions, isValidating: subscriptionsLoading } =
|
||||
const { subscriptions, isLoading: subscriptionsLoading } =
|
||||
useGetSubscriptionsQuery()
|
||||
|
||||
return (
|
||||
|
||||
@ -4,6 +4,7 @@ import { Label, labelFragment } from '../fragments/labelFragment'
|
||||
import { publicGqlFetcher } from '../networkHelpers'
|
||||
|
||||
type LabelsQueryResponse = {
|
||||
isLoading: boolean
|
||||
isValidating: boolean
|
||||
labels: Label[]
|
||||
revalidate: () => void
|
||||
@ -41,6 +42,7 @@ export function useGetLabelsQuery(): LabelsQueryResponse {
|
||||
const result = data as LabelsResponseData
|
||||
const labels = result.labels?.labels as Label[]
|
||||
return {
|
||||
isLoading: !error && !data,
|
||||
isValidating,
|
||||
labels,
|
||||
revalidate: () => {
|
||||
@ -52,6 +54,7 @@ export function useGetLabelsQuery(): LabelsQueryResponse {
|
||||
console.log('error', error)
|
||||
}
|
||||
return {
|
||||
isLoading: !error && !data,
|
||||
isValidating: false,
|
||||
labels: [],
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
|
||||
@ -25,6 +25,7 @@ export type Subscription = {
|
||||
}
|
||||
|
||||
type SubscriptionsQueryResponse = {
|
||||
isLoading: boolean
|
||||
isValidating: boolean
|
||||
subscriptions: Subscription[]
|
||||
revalidate: () => void
|
||||
@ -84,6 +85,7 @@ export function useGetSubscriptionsQuery(
|
||||
const result = data as SubscriptionsResponseData
|
||||
const subscriptions = result.subscriptions.subscriptions as Subscription[]
|
||||
return {
|
||||
isLoading: !error && !data,
|
||||
isValidating,
|
||||
subscriptions,
|
||||
revalidate: () => {
|
||||
@ -95,6 +97,7 @@ export function useGetSubscriptionsQuery(
|
||||
console.log('error', error)
|
||||
}
|
||||
return {
|
||||
isLoading: !error && !data,
|
||||
isValidating: true,
|
||||
subscriptions: [],
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
|
||||
Reference in New Issue
Block a user