From fd2b61529a5853e6bdc64cc46d7524b00f3bcf91 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 2 Oct 2015 18:53:46 +0300 Subject: [PATCH] Enabled file caching in Safari 9 --- app/js/lib/ng_utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index cf07b0f8..89ae3291 100644 --- a/app/js/lib/ng_utils.js +++ b/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 if (storageIsAvailable && navigator.userAgent.indexOf('Safari') != -1 && - navigator.userAgent.indexOf('Chrome') == -1 - // && navigator.userAgent.match(/Version\/([67]|8.0.[012])/) + navigator.userAgent.indexOf('Chrome') == -1 && + navigator.userAgent.match(/Version\/[678]/) ) { storageIsAvailable = false; } @@ -446,6 +446,9 @@ angular.module('izhukov.utils', []) }; function saveFileBase64(db, fileName, blob) { + if (getBlobSize(blob) > 10 * 1024 * 1024) { + return $q.reject(); + } try { var reader = new FileReader(); reader.readAsDataURL(blob); @@ -477,6 +480,10 @@ angular.module('izhukov.utils', []) return deferred.promise; } + function getBlobSize (blob) { + return blob.size || blob.byteLength || blob.length; + } + function getFile (fileName) { return openDatabase().then(function (db) { var deferred = $q.defer(),