Browse Source

Enabled file caching in Safari 9

master
Igor Zhukov 9 years ago
parent
commit
fd2b61529a
  1. 11
      app/js/lib/ng_utils.js

11
app/js/lib/ng_utils.js

@ -348,8 +348,8 @@ angular.module('izhukov.utils', [])
// IndexedDB is REALLY slow without blob support in Safari 8, no point in it // IndexedDB is REALLY slow without blob support in Safari 8, no point in it
if (storageIsAvailable && if (storageIsAvailable &&
navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Safari') != -1 &&
navigator.userAgent.indexOf('Chrome') == -1 navigator.userAgent.indexOf('Chrome') == -1 &&
// && navigator.userAgent.match(/Version\/([67]|8.0.[012])/) navigator.userAgent.match(/Version\/[678]/)
) { ) {
storageIsAvailable = false; storageIsAvailable = false;
} }
@ -446,6 +446,9 @@ angular.module('izhukov.utils', [])
}; };
function saveFileBase64(db, fileName, blob) { function saveFileBase64(db, fileName, blob) {
if (getBlobSize(blob) > 10 * 1024 * 1024) {
return $q.reject();
}
try { try {
var reader = new FileReader(); var reader = new FileReader();
reader.readAsDataURL(blob); reader.readAsDataURL(blob);
@ -477,6 +480,10 @@ angular.module('izhukov.utils', [])
return deferred.promise; return deferred.promise;
} }
function getBlobSize (blob) {
return blob.size || blob.byteLength || blob.length;
}
function getFile (fileName) { function getFile (fileName) {
return openDatabase().then(function (db) { return openDatabase().then(function (db) {
var deferred = $q.defer(), var deferred = $q.defer(),

Loading…
Cancel
Save