Skip to content

Commit

Permalink
if there's a token we're previewing - also await non node root fields…
Browse files Browse the repository at this point in the history
… for previews
  • Loading branch information
TylerBarnes committed Jan 18, 2023
1 parent ac0e309 commit 541f833
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,19 @@ import { sourcePreviews } from "~/steps/preview"
const sourceNodes: Step = async helpers => {
const { cache, webhookBody, refetchAll } = helpers

// fetch non-node root fields such as settings.
// For now, we're refetching them on every build
const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields()

// if this is a preview we want to process it and return early
if (webhookBody.preview) {
if (webhookBody.token && webhookBody.userDatabaseId) {
await sourcePreviews(helpers)

await nonNodeRootFieldsPromise
return
}
// if it's not a preview but we have a token
// we should source any pending previews then continue sourcing
else if (webhookBody.token && webhookBody.userDatabaseId) {
await sourcePreviews(helpers)
}

const now = Date.now()

// fetch non-node root fields such as settings.
// For now, we're refetching them on every build
const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields()

const lastCompletedSourceTime =
webhookBody.refreshing && webhookBody.since
? webhookBody.since
Expand Down

0 comments on commit 541f833

Please sign in to comment.