diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2016-08-01 16:43:27 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2016-08-01 16:43:27 -0400 |
| commit | 69e7033fca28646d1f3f2c78db6e0e6c2796c3e8 (patch) | |
| tree | dc9cb04aeaaf961e776645b656a9f4dc4e457025 /www/lib/localforage/src/utils/isIndexedDBValid.js | |
| parent | 81d24bbed0af0ba7b39948ca968528b225a46c76 (diff) | |
#292 - various items cleaned up, default to sqlite for devices, cleaned up entry paths to PortalLogin and ensured its AFTER DataModel.init() - wonder if this fixes #193
Former-commit-id: fbe5c0b0649b44912f5a52babeea5aa91a58e70f
Diffstat (limited to 'www/lib/localforage/src/utils/isIndexedDBValid.js')
| -rw-r--r-- | www/lib/localforage/src/utils/isIndexedDBValid.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/www/lib/localforage/src/utils/isIndexedDBValid.js b/www/lib/localforage/src/utils/isIndexedDBValid.js new file mode 100644 index 00000000..aa14b6d8 --- /dev/null +++ b/www/lib/localforage/src/utils/isIndexedDBValid.js @@ -0,0 +1,37 @@ +import idb from './idb'; + +function isIndexedDBValid() { + try { + // Initialize IndexedDB; fall back to vendor-prefixed versions + // if needed. + if (!idb) { + return false; + } + // We mimic PouchDB here; just UA test for Safari (which, as of + // iOS 8/Yosemite, doesn't properly support IndexedDB). + // IndexedDB support is broken and different from Blink's. + // This is faster than the test case (and it's sync), so we just + // do this. *SIGH* + // http://bl.ocks.org/nolanlawson/raw/c83e9039edf2278047e9/ + // + // We test for openDatabase because IE Mobile identifies itself + // as Safari. Oh the lulz... + if (typeof openDatabase !== 'undefined' && typeof navigator !== 'undefined' && + navigator.userAgent && + /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) { + return false; + } + + return idb && + typeof idb.open === 'function' && + // Some Samsung/HTC Android 4.0-4.3 devices + // have older IndexedDB specs; if this isn't available + // their IndexedDB is too old for us to use. + // (Replaces the onupgradeneeded test.) + typeof IDBKeyRange !== 'undefined'; + } catch (e) { + return false; + } +} + +export default isIndexedDBValid; |
