fix: remove unnecessary function cache (#1358)

This is just a bit of code cleanup; I think this cache logic is excessive
consolidate-ua-sniffing
Nolan Lawson 2019-07-23 20:33:31 -07:00 zatwierdzone przez GitHub
rodzic fbcac6d3e4
commit 6c58052684
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 5 dodań i 13 usunięć

Wyświetl plik

@ -1,11 +0,0 @@
// Rough guess at whether this is a "mobile" device or not, for the purposes
// of "device class" estimations
let cached
export function isMobile () {
if (typeof cached === 'undefined') {
cached = !!(process.browser && navigator.userAgent.match(/(iPhone|iPod|iPad|Android)/))
}
return cached
}

Wyświetl plik

@ -1,6 +1,9 @@
import { scheduleIdleTask } from './scheduleIdleTask'
import { store } from '../_store/store'
import { isMobile } from './isMobile'
// Rough guess at whether this is a "mobile" device or not, for the purposes
// of "device class" estimations
const IS_MOBILE = process.browser && navigator.userAgent.match(/(?:iPhone|iPod|iPad|Android)/)
// Run a task that doesn't need to be processed immediately, but should
// probably be delayed if we're on a mobile device. Also run it sooner
@ -8,7 +11,7 @@ import { isMobile } from './isMobile'
export function runMediumPriorityTask (fn) {
if (store.get().pageVisibilityHidden) {
fn()
} else if (isMobile()) {
} else if (IS_MOBILE) {
scheduleIdleTask(fn)
} else {
requestAnimationFrame(fn)