Skip to content

Commit e0d59bf

Browse files
committed
calculate goodConnection with puppeteer in mind
1 parent 19c5494 commit e0d59bf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/getInitialState.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ const buildRoutesObject = (routes) => Object.keys(routes).reduce((routesObj, rou
1313
}
1414
}), window.initialState ? window.initialState.routes : {})
1515

16+
17+
// TODO: use something more reliable
18+
const connSpeed = navigator.connection ? navigator.connection.downlink : 10
19+
const goodConnection = window.navigator.userAgent === 'puppeteer'
20+
? false
21+
: connSpeed > 2
22+
23+
1624
export const getInitialState = (routes, extraInit) => {
1725
const init = {
18-
goodConnection: navigator.connection.downlink > 2, // TODO: use something more reliable, maybe an effect
26+
goodConnection,
1927
location: {
2028
path: '/',
2129
params: {},

0 commit comments

Comments
 (0)