From 990bed0729fe0e10d6b5537c6721775ad976129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?= Date: Thu, 5 Oct 2023 16:15:07 -0400 Subject: [PATCH] Update networkUtils.js to check saveData mode --- .../src/ServiceWorker/Utilities/networkUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/venia-concept/src/ServiceWorker/Utilities/networkUtils.js b/packages/venia-concept/src/ServiceWorker/Utilities/networkUtils.js index 29de8d7f43..3fa8fd16a1 100644 --- a/packages/venia-concept/src/ServiceWorker/Utilities/networkUtils.js +++ b/packages/venia-concept/src/ServiceWorker/Utilities/networkUtils.js @@ -1,7 +1,8 @@ /** * isFastNetwork uses the navigator API to tell if a connection * is fast or not. It returns true if the connection is 4g which - * is same for 4g, LTE and WiFi. + * is same for 4g, LTE and WiFi. And if the Save-Data preference + * isn't turned on. * * The new navigator API will have a more granular distribution * for different types of connections once it is published. @@ -9,7 +10,7 @@ * @returns {boolean} */ export const isFastNetwork = () => { - if (navigator.connection && 'effectiveType' in navigator.connection) { + if (navigator.connection && 'effectiveType' in navigator.connection && !navigator.connection.saveData) { return navigator.connection.effectiveType === '4g'; } else { /**