Skip to content

Commit

Permalink
More consistent codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
vladar committed Nov 16, 2020
1 parent 40a194a commit 49ec489
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/gatsby/src/redux/reducers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ export function queriesReducer(
}
if (component.query !== query) {
// Invalidate all pages associated with a component when query text changes
component.pages.forEach(queryId => {
for (const queryId of component.pages) {
const query = state.trackedQueries.get(queryId)
if (query) {
query.dirty = setFlag(query.dirty, FLAG_DIRTY_TEXT)
}
})
}
component.query = query
}
return state
Expand Down Expand Up @@ -165,18 +165,18 @@ export function queriesReducer(
const queriesByConnection =
state.byConnection.get(node.internal.type) ?? []

queriesByNode.forEach(queryId => {
for (const queryId of queriesByNode) {
const query = state.trackedQueries.get(queryId)
if (query) {
query.dirty = setFlag(query.dirty, FLAG_DIRTY_DATA)
}
})
queriesByConnection.forEach(queryId => {
}
for (const queryId of queriesByConnection) {
const query = state.trackedQueries.get(queryId)
if (query) {
query.dirty = setFlag(query.dirty, FLAG_DIRTY_DATA)
}
})
}
return state
}
case `PAGE_QUERY_RUN`: {
Expand Down Expand Up @@ -231,9 +231,12 @@ function addConnectionDependency(
): IGatsbyState["queries"] {
// Note: not using two-side maps for connections as associated overhead
// for small number of elements is greater then benefits, so no perf. gains
const queryIds = state.byConnection.get(connection) ?? new Set<QueryId>()
let queryIds = state.byConnection.get(connection)
if (!queryIds) {
queryIds = new Set()
state.byConnection.set(connection, queryIds)
}
queryIds.add(queryId)
state.byConnection.set(connection, queryIds)
return state
}

Expand All @@ -255,9 +258,9 @@ function clearConnectionDependencies(
state: IGatsbyState["queries"],
queryId: QueryId
): IGatsbyState["queries"] {
state.byConnection.forEach(queryIds => {
for (const [, queryIds] of state.byConnection) {
queryIds.delete(queryId)
})
}
return state
}

Expand Down

0 comments on commit 49ec489

Please sign in to comment.