mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-20 06:56:40 +02:00
Finished with async settings store,
Removed cloud drives from cordova
This commit is contained in:
parent
b35edd8c9c
commit
a9d3b08c49
|
@ -11,9 +11,12 @@ const FileInfoCollection = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
load: function () {
|
||||
const data = SettingsStore.load('file-info');
|
||||
SettingsStore.load('file-info', this.onLoaded.bind(this));
|
||||
},
|
||||
|
||||
onLoaded: function(data) {
|
||||
if (data) {
|
||||
this.reset(data, {silent: true});
|
||||
this.reset(data, { silent: true });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const Launcher = false; // require('./launcher');
|
||||
const Launcher = require('./launcher');
|
||||
const StringUtil = require('../util/string-util');
|
||||
const Logger = require('../util/logger');
|
||||
|
||||
|
@ -12,7 +12,7 @@ const SettingsStore = {
|
|||
return `${key}.json`;
|
||||
},
|
||||
|
||||
load: function(key, callback, error) {
|
||||
load: function(key, callback) {
|
||||
try {
|
||||
if (Launcher) {
|
||||
const settingsFile = Launcher.getUserDataPath(this.fileName(key));
|
||||
|
@ -20,7 +20,9 @@ const SettingsStore = {
|
|||
if (exists) {
|
||||
Launcher.readFile(settingsFile, data => {
|
||||
callback(JSON.parse(data));
|
||||
}, error);
|
||||
}, err => { // eslint-disable-line handle-callback-err
|
||||
callback(undefined);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -32,13 +34,14 @@ const SettingsStore = {
|
|||
}
|
||||
},
|
||||
|
||||
save: function(key, data, callback, error) {
|
||||
save: function(key, data, callback) {
|
||||
try {
|
||||
if (Launcher) {
|
||||
const settingsFile = Launcher.getUserDataPath(this.fileName(key));
|
||||
Launcher.writeFile(settingsFile, JSON.stringify(data), callback, error);
|
||||
Launcher.writeFile(settingsFile, JSON.stringify(data), callback, callback);
|
||||
} else if (typeof localStorage !== 'undefined') {
|
||||
localStorage[StringUtil.camelCase(key)] = JSON.stringify(data);
|
||||
callback && callback();
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`Error saving ${key}`, e);
|
||||
|
|
|
@ -46,7 +46,10 @@ const AppSettingsModel = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
load: function() {
|
||||
const data = SettingsStore.load('app-settings');
|
||||
SettingsStore.load('app-settings', this.onLoaded.bind(this));
|
||||
},
|
||||
|
||||
onLoaded: function(data) {
|
||||
if (data) {
|
||||
this.upgrade(data);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ const RuntimeDataModel = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
load: function() {
|
||||
const data = SettingsStore.load('runtime-data');
|
||||
SettingsStore.load('runtime-data', this.onLoaded.bind(this));
|
||||
},
|
||||
|
||||
onLoaded: function(data) {
|
||||
if (data) {
|
||||
this.set(data, {silent: true});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,10 @@ const UpdateModel = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
load: function() {
|
||||
const data = SettingsStore.load('update-info');
|
||||
SettingsStore.load('update-info', this.onLoaded.bind(this));
|
||||
},
|
||||
|
||||
onLoaded: function(data) {
|
||||
if (data) {
|
||||
try {
|
||||
_.each(data, (val, key) => {
|
||||
|
|
|
@ -2,13 +2,24 @@
|
|||
|
||||
const Launcher = require('../comp/launcher');
|
||||
|
||||
const Storage = {
|
||||
const FileStorage = {
|
||||
file: require('./storage-file'),
|
||||
dropbox: require('./storage-dropbox'),
|
||||
webdav: require('./storage-webdav'),
|
||||
gdrive: require('./storage-gdrive'),
|
||||
onedrive: require('./storage-onedrive'),
|
||||
cache: Launcher ? require('./storage-file-cache') : require('./storage-cache')
|
||||
};
|
||||
|
||||
const ThirdPartyStorage = {
|
||||
dropbox: require('./storage-dropbox'),
|
||||
webdav: require('./storage-webdav'),
|
||||
gdrive: require('./storage-gdrive'),
|
||||
onedrive: require('./storage-onedrive')
|
||||
};
|
||||
|
||||
let Storage = [];
|
||||
|
||||
if (window.cordova) {
|
||||
Storage = FileStorage;
|
||||
} else {
|
||||
Storage = FileStorage.concat(ThirdPartyStorage);
|
||||
}
|
||||
|
||||
module.exports = Storage;
|
||||
|
|
Loading…
Reference in New Issue
Block a user