-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(entry): added battery level check #851
Changes from 1 commit
643d417
b107660
bfef734
2bf6714
2b9206c
5d5332e
54ceb68
a3b9487
2ac023e
a6f10fc
9054d5b
90a2f66
565125b
8da3062
b2d7037
74d6ae9
6d47219
388bfd8
a1f014f
2b3a45d
65c27a5
bcc5821
df17692
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we implement a generalistic solution. so it also works on ios and in desktop browsers (laptop) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two different checks.
Checking sequence The check is placed in the entry before the performance check and triggers a separate message in the layer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the silent catch to switch to video detection. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,17 @@ export function initReducedView() { | |
tmp.remove(); | ||
}); | ||
} | ||
|
||
const MIN_BATTERY_LEVEL = 0.2; | ||
// https://blog.google/products/chrome/new-chrome-features-to-save-battery-and-make-browsing-smoother/ | ||
export async function hasBatteryPerformanceIssue() { | ||
try { | ||
const battery = await window.navigator.getBattery(); | ||
if (!battery.charging && battery.level <= MIN_BATTERY_LEVEL) { | ||
return true; | ||
} | ||
} catch (error) { | ||
// Ignore Check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. silent catch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it it helpful to create an ignore object? so we have an easy possibility to extend it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready!
https://github.com/GrabarzUndPartner/nuxt-speedkit/blob/54ceb684812d31f777ec67e8bbb5ca841854d833/src/module.mjs#L147-L150