|
|
@ -193,7 +193,7 @@ export default () => { |
|
|
* @returns {Object} |
|
|
* @returns {Object} |
|
|
* */ |
|
|
* */ |
|
|
getStorageOptions(type) { |
|
|
getStorageOptions(type) { |
|
|
return this.getCurrentOptons(type); |
|
|
return this.getCurrentOptions(type); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -207,9 +207,9 @@ export default () => { |
|
|
* */ |
|
|
* */ |
|
|
async store(data, options = {}) { |
|
|
async store(data, options = {}) { |
|
|
const st = this.getCurrentStorage(); |
|
|
const st = this.getCurrentStorage(); |
|
|
const opts = { ...this.getCurrentOptons(), ...options }; |
|
|
const opts = { ...this.getCurrentOptions(), ...options }; |
|
|
const recovery = this.getRecoveryStorage(); |
|
|
const recovery = this.getRecoveryStorage(); |
|
|
const recoveryOpts = this.getCurrentOptons(STORAGE_LOCAL); |
|
|
const recoveryOpts = this.getCurrentOptions(STORAGE_LOCAL); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
await this.__exec(st, opts, data); |
|
|
await this.__exec(st, opts, data); |
|
|
@ -235,12 +235,12 @@ export default () => { |
|
|
* */ |
|
|
* */ |
|
|
async load(options = {}) { |
|
|
async load(options = {}) { |
|
|
const st = this.getCurrentStorage(); |
|
|
const st = this.getCurrentStorage(); |
|
|
const opts = { ...this.getCurrentOptons(), ...options }; |
|
|
const opts = { ...this.getCurrentOptions(), ...options }; |
|
|
const recoveryStorage = this.getRecoveryStorage(); |
|
|
const recoveryStorage = this.getRecoveryStorage(); |
|
|
let result; |
|
|
let result; |
|
|
|
|
|
|
|
|
if (recoveryStorage) { |
|
|
if (recoveryStorage) { |
|
|
const recoveryData = await this.__exec(recoveryStorage, this.getCurrentOptons(STORAGE_LOCAL)); |
|
|
const recoveryData = await this.__exec(recoveryStorage, this.getCurrentOptions(STORAGE_LOCAL)); |
|
|
if (!isEmpty(recoveryData)) { |
|
|
if (!isEmpty(recoveryData)) { |
|
|
try { |
|
|
try { |
|
|
await this.__askRecovery(); |
|
|
await this.__askRecovery(); |
|
|
@ -326,7 +326,7 @@ export default () => { |
|
|
return result; |
|
|
return result; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
getCurrentOptons(type) { |
|
|
getCurrentOptions(type) { |
|
|
const config = this.getConfig(); |
|
|
const config = this.getConfig(); |
|
|
const current = type || this.getCurrent(); |
|
|
const current = type || this.getCurrent(); |
|
|
return config.options[current] || {}; |
|
|
return config.options[current] || {}; |
|
|
@ -395,6 +395,6 @@ export default () => { |
|
|
destroy() { |
|
|
destroy() { |
|
|
this.__destroy(); |
|
|
this.__destroy(); |
|
|
this.storages = {}; |
|
|
this.storages = {}; |
|
|
}, |
|
|
} |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
|