keeweb/app/scripts/models/runtime-data-model.js

31 lines
781 B
JavaScript
Raw Normal View History

2017-01-31 07:50:28 +01:00
const Backbone = require('backbone');
const SettingsStore = require('../comp/settings-store');
2016-03-27 14:57:22 +02:00
2017-01-31 07:50:28 +01:00
const RuntimeDataModel = Backbone.Model.extend({
2016-03-27 14:57:22 +02:00
defaults: {},
initialize: function() {
this.listenTo(this, 'change', this.save);
},
load: function() {
return SettingsStore.load('runtime-data').then(data => {
if (data) {
2019-01-06 23:33:09 +01:00
if (data.cookies) {
2019-01-06 23:34:39 +01:00
// we're not using cookies here now
2019-01-06 23:33:09 +01:00
delete data.cookies;
}
2019-08-16 23:05:39 +02:00
this.set(data, { silent: true });
}
});
},
2016-03-27 14:57:22 +02:00
save: function() {
SettingsStore.save('runtime-data', this.attributes);
}
});
RuntimeDataModel.instance = new RuntimeDataModel();
module.exports = RuntimeDataModel;