This repository was archived by the owner on Jan 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from 'react'
2
2
import match from 'match-sorter'
3
3
import { queryCache as cache , useQueryCache } from 'react-query'
4
4
import useLocalStorage from './useLocalStorage'
5
- import { useSafeState } from './utils'
5
+ import { useSafeState , isStale } from './utils'
6
6
7
7
import {
8
8
Panel ,
@@ -196,7 +196,7 @@ export function ReactQueryDevtools({
196
196
}
197
197
198
198
const getStatusRank = q =>
199
- q . state . isFetching ? 0 : ! q . observers . length ? 3 : q . state . isStale ? 2 : 1
199
+ q . state . isFetching ? 0 : ! q . observers . length ? 3 : isStale ( q ) ? 2 : 1
200
200
201
201
const sortFns = {
202
202
'Status > Last Updated' : ( a , b ) =>
Original file line number Diff line number Diff line change @@ -5,10 +5,16 @@ import useMediaQuery from './useMediaQuery'
5
5
6
6
export const isServer = typeof window === 'undefined'
7
7
8
+ export function isStale ( query ) {
9
+ return typeof query . isStale === 'function'
10
+ ? query . isStale ( )
11
+ : query . state . isStale
12
+ }
13
+
8
14
export function getQueryStatusColor ( query , theme ) {
9
15
return query . state . isFetching
10
16
? theme . active
11
- : query . state . isStale
17
+ : isStale ( query )
12
18
? theme . warning
13
19
: theme . success
14
20
}
@@ -22,7 +28,7 @@ export function getQueryStatusLabel(query) {
22
28
? 'fetching'
23
29
: ! query . observers . length
24
30
? 'inactive'
25
- : query . state . isStale
31
+ : isStale ( query )
26
32
? 'stale'
27
33
: 'fresh'
28
34
}
You can’t perform that action at this time.
0 commit comments