master: change repo
This commit is contained in:
21
src/utils/network.ts
Normal file
21
src/utils/network.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
declare var navigator: any
|
||||
|
||||
export const hasGoodNetwork = (): boolean => {
|
||||
const connection =
|
||||
navigator.connection ||
|
||||
navigator.mozConnection ||
|
||||
navigator.webkitConnection
|
||||
|
||||
if (connection) {
|
||||
if (connection.effectiveType) {
|
||||
const goodNetworks: string[] = ['3g', '4g']
|
||||
return goodNetworks.includes(connection.effectiveType)
|
||||
} else {
|
||||
const highBandwidth: boolean =
|
||||
connection.metered && (connection.bandwidth || 0) > 2
|
||||
return highBandwidth
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user