Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pendingQueryRuns available on the event #36393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/gatsby/src/services/calculate-dirty-queries.ts
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
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
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
Expand Up @@ -23,5 +23,4 @@ export interface IQueryRunningContext {
websocketManager?: WebsocketManager
filesDirty?: boolean
pendingQueryRuns?: Set<string>
currentlyHandledPendingQueryRuns?: Set<string>
}