Disabled IndexedDB workaround

Closes #336
This commit is contained in:
Igor Zhukov 2014-06-21 11:12:34 +04:00
parent 3d512bf5c4
commit 9b620ba18a

View File

@ -294,19 +294,24 @@ angular.module('izhukov.utils', [])
return openDbPromise;
}
var request = indexedDB.open(dbName, dbVersion),
deferred = $q.defer(),
createObjectStore = function (db) {
db.createObjectStore(dbStoreName);
};
try {
var request = indexedDB.open(dbName, dbVersion),
deferred = $q.defer(),
createObjectStore = function (db) {
db.createObjectStore(dbStoreName);
};
} catch (error) {
storageIsAvailable = false;
return $q.reject(error);
}
request.onsuccess = function (event) {
db = request.result;
db.onerror = function (event) {
db.onerror = function (error) {
storageIsAvailable = false;
console.error("Error creating/accessing IndexedDB database", event);
deferred.reject(event);
console.error('Error creating/accessing IndexedDB database', error);
deferred.reject(error);
};
// Interim solution for Google Chrome to create an objectStore. Will be deprecated
@ -326,6 +331,12 @@ angular.module('izhukov.utils', [])
}
};
request.onerror = function (event) {
storageIsAvailable = false;
console.error('Error creating/accessing IndexedDB database', event);
deferred.reject(event);
}
request.onupgradeneeded = function (event) {
createObjectStore(event.target.result);
};
@ -385,6 +396,8 @@ angular.module('izhukov.utils', [])
return $q.when(fakeWriter);
}
openDatabase();
return {
isAvailable: isAvailable,
saveFile: saveFile,
@ -481,6 +494,8 @@ angular.module('izhukov.utils', [])
})
}
requestFS();
return {
isAvailable: isAvailable,
saveFile: saveFile,