Skip to content

Commit 49ec489

Browse files
committed
More consistent codestyle
1 parent 40a194a commit 49ec489

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/gatsby/src/redux/reducers/queries.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ export function queriesReducer(
107107
}
108108
if (component.query !== query) {
109109
// Invalidate all pages associated with a component when query text changes
110-
component.pages.forEach(queryId => {
110+
for (const queryId of component.pages) {
111111
const query = state.trackedQueries.get(queryId)
112112
if (query) {
113113
query.dirty = setFlag(query.dirty, FLAG_DIRTY_TEXT)
114114
}
115-
})
115+
}
116116
component.query = query
117117
}
118118
return state
@@ -165,18 +165,18 @@ export function queriesReducer(
165165
const queriesByConnection =
166166
state.byConnection.get(node.internal.type) ?? []
167167

168-
queriesByNode.forEach(queryId => {
168+
for (const queryId of queriesByNode) {
169169
const query = state.trackedQueries.get(queryId)
170170
if (query) {
171171
query.dirty = setFlag(query.dirty, FLAG_DIRTY_DATA)
172172
}
173-
})
174-
queriesByConnection.forEach(queryId => {
173+
}
174+
for (const queryId of queriesByConnection) {
175175
const query = state.trackedQueries.get(queryId)
176176
if (query) {
177177
query.dirty = setFlag(query.dirty, FLAG_DIRTY_DATA)
178178
}
179-
})
179+
}
180180
return state
181181
}
182182
case `PAGE_QUERY_RUN`: {
@@ -231,9 +231,12 @@ function addConnectionDependency(
231231
): IGatsbyState["queries"] {
232232
// Note: not using two-side maps for connections as associated overhead
233233
// for small number of elements is greater then benefits, so no perf. gains
234-
const queryIds = state.byConnection.get(connection) ?? new Set<QueryId>()
234+
let queryIds = state.byConnection.get(connection)
235+
if (!queryIds) {
236+
queryIds = new Set()
237+
state.byConnection.set(connection, queryIds)
238+
}
235239
queryIds.add(queryId)
236-
state.byConnection.set(connection, queryIds)
237240
return state
238241
}
239242

@@ -255,9 +258,9 @@ function clearConnectionDependencies(
255258
state: IGatsbyState["queries"],
256259
queryId: QueryId
257260
): IGatsbyState["queries"] {
258-
state.byConnection.forEach(queryIds => {
261+
for (const [, queryIds] of state.byConnection) {
259262
queryIds.delete(queryId)
260-
})
263+
}
261264
return state
262265
}
263266

0 commit comments

Comments
 (0)