Skip to content

Commit

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

export async function calculateDirtyQueries(
{ store, websocketManager }: Partial<IQueryRunningContext>,
{
pendingQueryRuns: currentlyHandledPendingQueryRuns,
}: {
pendingQueryRuns?: Set<string>
} = {}
): Promise<{
export async function calculateDirtyQueries({
store,
websocketManager,
currentlyHandledPendingQueryRuns,
}: Partial<IQueryRunningContext>): Promise<{
queryIds: IGroupedQueryIds
}> {
assertStore(store)
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby/src/state-machines/query-running/actions.ts
Expand Up @@ -42,10 +42,16 @@ 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: 9 additions & 3 deletions packages/gatsby/src/state-machines/query-running/index.ts
Expand Up @@ -62,15 +62,21 @@ export const queryStates: MachineConfig<IQueryRunningContext, any, any> = {
},
},
calculatingDirtyQueries: {
entry: assign({
pendingQueryRuns: new Set(),
entry: assign<IQueryRunningContext>(({ pendingQueryRuns }) => {
return {
pendingQueryRuns: new Set(),
currentlyHandledPendingQueryRuns: pendingQueryRuns,
}
}),
invoke: {
id: `calculating-dirty-queries`,
src: `calculateDirtyQueries`,
onDone: {
target: `runningStaticQueries`,
actions: [`assignDirtyQueries`],
actions: [
`assignDirtyQueries`,
`clearCurrentlyHandledPendingQueryRuns`,
],
},
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/state-machines/query-running/types.ts
Expand Up @@ -23,4 +23,5 @@ export interface IQueryRunningContext {
websocketManager?: WebsocketManager
filesDirty?: boolean
pendingQueryRuns?: Set<string>
currentlyHandledPendingQueryRuns?: Set<string>
}

0 comments on commit 7b02bb8

Please sign in to comment.