Return promise results from PiskelDB and IndexedDBStorageService

This commit is contained in:
Julian Descottes 2017-10-17 02:11:08 +02:00
parent 3e779a651f
commit a69b44eaec
2 changed files with 6 additions and 6 deletions

View File

@ -29,9 +29,7 @@
return _requestPromise(request).then(function (event) { return _requestPromise(request).then(function (event) {
this.db = event.target.result; this.db = event.target.result;
return this.db; return this.db;
}.bind(this)).catch(function (e) { }.bind(this));
console.log('Failed to initialize IndexedDB, local browser saves will be unavailable.');
});
}; };
ns.PiskelDatabase.prototype.onUpgradeNeeded_ = function (event) { ns.PiskelDatabase.prototype.onUpgradeNeeded_ = function (event) {

View File

@ -7,7 +7,9 @@
}; };
ns.IndexedDbStorageService.prototype.init = function () { ns.IndexedDbStorageService.prototype.init = function () {
this.piskelDatabase.init(); this.piskelDatabase.init().catch(function (e) {
console.log('Failed to initialize PiskelDatabase, local browser saves will be unavailable.');
});
}; };
ns.IndexedDbStorageService.prototype.save = function (piskel) { ns.IndexedDbStorageService.prototype.save = function (piskel) {
@ -30,7 +32,7 @@
}; };
ns.IndexedDbStorageService.prototype.load = function (name) { ns.IndexedDbStorageService.prototype.load = function (name) {
this.piskelDatabase.get(name).then(function (piskelData) { return this.piskelDatabase.get(name).then(function (piskelData) {
if (typeof piskelData !== 'undefined') { if (typeof piskelData !== 'undefined') {
var serialized = piskelData.serialized; var serialized = piskelData.serialized;
pskl.utils.serialization.Deserializer.deserialize( pskl.utils.serialization.Deserializer.deserialize(
@ -46,7 +48,7 @@
}; };
ns.IndexedDbStorageService.prototype.remove = function (name) { ns.IndexedDbStorageService.prototype.remove = function (name) {
this.piskelDatabase.delete(name); return this.piskelDatabase.delete(name);
}; };
ns.IndexedDbStorageService.prototype.getKeys = function () { ns.IndexedDbStorageService.prototype.getKeys = function () {