Skip to content

Commit 904d076

Browse files
ci: apply automated fixes
1 parent 79a01d5 commit 904d076

File tree

3 files changed

+71
-21
lines changed

3 files changed

+71
-21
lines changed

packages/query-devtools/src/Devtools.tsx

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ import {
5151
XCircle,
5252
} from './icons'
5353
import Explorer from './Explorer'
54-
import { DevtoolsStateContext, useDevtoolsState, usePiPWindow, useQueryDevtoolsContext, useTheme } from './contexts'
54+
import {
55+
DevtoolsStateContext,
56+
useDevtoolsState,
57+
usePiPWindow,
58+
useQueryDevtoolsContext,
59+
useTheme,
60+
} from './contexts'
5561
import {
5662
BUTTON_POSITION,
5763
DEFAULT_HEIGHT,
@@ -106,8 +112,12 @@ export type DevtoolsComponentType = Component<QueryDevtoolsProps> & {
106112
}
107113

108114
export const Devtools: Component<DevtoolsPanelProps> = (props) => {
109-
const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(null)
110-
const [selectedMutationId, setSelectedMutationId] = createSignal<number | null>(null)
115+
const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(
116+
null,
117+
)
118+
const [selectedMutationId, setSelectedMutationId] = createSignal<
119+
number | null
120+
>(null)
111121
const [panelWidth, setPanelWidth] = createSignal(0)
112122
const [offline, setOffline] = createSignal(false)
113123
const queryCacheMap: QueryCacheMap = new Map()
@@ -193,7 +203,20 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
193203
)
194204

195205
return (
196-
<DevtoolsStateContext.Provider value={{ selectedQueryHash, setSelectedQueryHash, selectedMutationId, setSelectedMutationId, panelWidth, setPanelWidth, offline, setOffline, queryCacheMap, mutationCacheMap }}>
206+
<DevtoolsStateContext.Provider
207+
value={{
208+
selectedQueryHash,
209+
setSelectedQueryHash,
210+
selectedMutationId,
211+
setSelectedMutationId,
212+
panelWidth,
213+
setPanelWidth,
214+
offline,
215+
setOffline,
216+
queryCacheMap,
217+
mutationCacheMap,
218+
}}
219+
>
197220
<Show when={pip().pipWindow && pip_open() == 'true'}>
198221
<Portal mount={pip().pipWindow?.document.body}>
199222
<PiPPanel>
@@ -693,7 +716,14 @@ export const ContentView: Component<ContentViewProps> = (props) => {
693716
'queries',
694717
)
695718

696-
const { selectedQueryHash, offline, setSelectedQueryHash, selectedMutationId, setSelectedMutationId, panelWidth } = useDevtoolsState()
719+
const {
720+
selectedQueryHash,
721+
offline,
722+
setSelectedQueryHash,
723+
selectedMutationId,
724+
setSelectedMutationId,
725+
panelWidth,
726+
} = useDevtoolsState()
697727

698728
const sort = createMemo(() => props.localStore.sort || DEFAULT_SORT_FN_NAME)
699729
const sortOrder = createMemo(
@@ -1390,7 +1420,6 @@ const QueryRow: Component<{ query: Query }> = (props) => {
13901420
const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
13911421
const { selectedQueryHash, setSelectedQueryHash } = useDevtoolsState()
13921422

1393-
13941423
const queryState = createSubscribeToQueryCacheBatcher(
13951424
(queryCache) =>
13961425
queryCache().find({
@@ -1522,7 +1551,6 @@ const MutationRow: Component<{ mutation: Mutation }> = (props) => {
15221551

15231552
const { selectedMutationId, setSelectedMutationId } = useDevtoolsState()
15241553

1525-
15261554
const mutationState = createSubscribeToMutationCacheBatcher(
15271555
(mutationCache) => {
15281556
const mutations = mutationCache().getAll()

packages/query-devtools/src/DevtoolsPanelComponent.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { createMemo, createSignal } from 'solid-js'
33
import { ContentView, ParentPanel } from './Devtools'
44
import { getPreferredColorScheme } from './utils'
55
import { THEME_PREFERENCE } from './constants'
6-
import { DevtoolsStateContext, PiPProvider, QueryDevtoolsContext, ThemeContext } from './contexts'
6+
import {
7+
DevtoolsStateContext,
8+
PiPProvider,
9+
QueryDevtoolsContext,
10+
ThemeContext,
11+
} from './contexts'
712
import type { MutationCacheMap, QueryCacheMap, Theme } from './contexts'
813
import type { DevtoolsComponentType } from './Devtools'
914

@@ -12,8 +17,12 @@ const DevtoolsPanelComponent: DevtoolsComponentType = (props) => {
1217
prefix: 'TanstackQueryDevtools',
1318
})
1419

15-
const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(null)
16-
const [selectedMutationId, setSelectedMutationId] = createSignal<number | null>(null)
20+
const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(
21+
null,
22+
)
23+
const [selectedMutationId, setSelectedMutationId] = createSignal<
24+
number | null
25+
>(null)
1726
const [panelWidth, setPanelWidth] = createSignal(0)
1827
const [offline, setOffline] = createSignal(false)
1928
const queryCacheMap: QueryCacheMap = new Map()
@@ -31,13 +40,20 @@ const DevtoolsPanelComponent: DevtoolsComponentType = (props) => {
3140

3241
return (
3342
<QueryDevtoolsContext.Provider value={props}>
34-
<DevtoolsStateContext.Provider value={{
35-
selectedQueryHash, setSelectedQueryHash,
36-
selectedMutationId, setSelectedMutationId,
37-
panelWidth, setPanelWidth,
38-
offline, setOffline,
39-
queryCacheMap, mutationCacheMap,
40-
}}>
43+
<DevtoolsStateContext.Provider
44+
value={{
45+
selectedQueryHash,
46+
setSelectedQueryHash,
47+
selectedMutationId,
48+
setSelectedMutationId,
49+
panelWidth,
50+
setPanelWidth,
51+
offline,
52+
setOffline,
53+
queryCacheMap,
54+
mutationCacheMap,
55+
}}
56+
>
4157
<PiPProvider
4258
disabled
4359
localStore={localStore}

packages/query-devtools/src/contexts/DevtoolsStateContext.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { createContext, useContext } from "solid-js"
2-
import type { Accessor, Setter } from "solid-js"
3-
import type { MutationCache, QueryCache, QueryCacheNotifyEvent } from "@tanstack/query-core"
1+
import { createContext, useContext } from 'solid-js'
2+
import type { Accessor, Setter } from 'solid-js'
3+
import type {
4+
MutationCache,
5+
QueryCache,
6+
QueryCacheNotifyEvent,
7+
} from '@tanstack/query-core'
48

59
export type QueryCacheMapValue = {
610
setter: Setter<any>
@@ -39,7 +43,9 @@ export const DevtoolsStateContext = createContext<DevtoolsState>()
3943
export function useDevtoolsState() {
4044
const context = useContext(DevtoolsStateContext)
4145
if (!context) {
42-
throw new Error('useDevtoolsState must be used within DevtoolsStateContext.Provider')
46+
throw new Error(
47+
'useDevtoolsState must be used within DevtoolsStateContext.Provider',
48+
)
4349
}
4450
return context
4551
}

0 commit comments

Comments
 (0)