Skip to content

Commit

Permalink
Use pendingQueryRuns available on the event (#36393)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Nov 16, 2022
1 parent ce74ec5 commit 9460dd3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
13 changes: 8 additions & 5 deletions packages/gatsby/src/services/calculate-dirty-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { IGroupedQueryIds } from "./"
import { IQueryRunningContext } from "../state-machines/query-running/types"
import { assertStore } from "../utils/assert-store"

export async function calculateDirtyQueries({
store,
websocketManager,
currentlyHandledPendingQueryRuns,
}: Partial<IQueryRunningContext>): Promise<{
export async function calculateDirtyQueries(
{ store, websocketManager }: Partial<IQueryRunningContext>,
{
pendingQueryRuns: currentlyHandledPendingQueryRuns,
}: {
pendingQueryRuns?: Set<string>
} = {}
): Promise<{
queryIds: IGroupedQueryIds
}> {
assertStore(store)
Expand Down
6 changes: 0 additions & 6 deletions packages/gatsby/src/state-machines/query-running/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@ export const trackRequestedQueryRun = assign<
},
})

export const clearCurrentlyHandledPendingQueryRuns =
assign<IQueryRunningContext>({
currentlyHandledPendingQueryRuns: undefined,
})

export const queryActions: ActionFunctionMap<IQueryRunningContext, any> = {
assignDirtyQueries,
flushPageData,
markSourceFilesDirty,
markSourceFilesClean,
trackRequestedQueryRun,
clearCurrentlyHandledPendingQueryRuns,
}
12 changes: 3 additions & 9 deletions packages/gatsby/src/state-machines/query-running/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,15 @@ export const queryStates: MachineConfig<IQueryRunningContext, any, any> = {
},
},
calculatingDirtyQueries: {
entry: assign<IQueryRunningContext>(({ pendingQueryRuns }) => {
return {
pendingQueryRuns: new Set(),
currentlyHandledPendingQueryRuns: pendingQueryRuns,
}
entry: assign({
pendingQueryRuns: new Set(),
}),
invoke: {
id: `calculating-dirty-queries`,
src: `calculateDirtyQueries`,
onDone: {
target: `runningStaticQueries`,
actions: [
`assignDirtyQueries`,
`clearCurrentlyHandledPendingQueryRuns`,
],
actions: [`assignDirtyQueries`],
},
},
},
Expand Down
1 change: 0 additions & 1 deletion packages/gatsby/src/state-machines/query-running/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ export interface IQueryRunningContext {
websocketManager?: WebsocketManager
filesDirty?: boolean
pendingQueryRuns?: Set<string>
currentlyHandledPendingQueryRuns?: Set<string>
}

0 comments on commit 9460dd3

Please sign in to comment.