Skip to content

Commit

Permalink
Empty out queuedDirtyActions after running initial queries
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Aug 22, 2017
1 parent 5dd46ee commit 87202a7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ const queryRunner = require(`./query-runner`)
let queuedDirtyActions = []
let active = false

// Do initial run of graphql queries during bootstrap.
// Afterwards we listen "API_RUNNING_QUEUE_EMPTY" and check
// for dirty nodes before running queries.
exports.runQueries = async () => {
active = true
const state = store.getState()

// Run queued dirty nodes now that we're active.
queuedDirtyActions = _.uniq(queuedDirtyActions, a => a.payload.id)
const dirtyIds = findDirtyIds(queuedDirtyActions)
await runQueriesForIds(dirtyIds)

queuedDirtyActions = []

// Find ids without data dependencies and run them (just in case?)
const cleanIds = findIdsWithoutDataDependencies()
// Run these pages
Expand Down Expand Up @@ -70,6 +74,7 @@ const findIdsWithoutDataDependencies = () => {
}

const runQueriesForIds = ids => {
ids = _.uniq(ids)
if (ids.length < 1) {
return Promise.resolve()
}
Expand Down

0 comments on commit 87202a7

Please sign in to comment.