2019-09-17 21:56:58 +02:00
|
|
|
import { Model } from 'framework/model';
|
2019-09-15 14:16:32 +02:00
|
|
|
import { SettingsStore } from 'comp/settings/settings-store';
|
2015-10-29 22:20:01 +01:00
|
|
|
|
2019-09-17 21:56:58 +02:00
|
|
|
class UpdateModel extends Model {
|
2019-08-18 10:17:09 +02:00
|
|
|
load() {
|
2017-02-20 23:39:13 +01:00
|
|
|
return SettingsStore.load('update-info').then(data => {
|
|
|
|
if (data) {
|
|
|
|
try {
|
2019-09-17 22:17:40 +02:00
|
|
|
for (const [key, val] of Object.entries(data)) {
|
2017-02-20 23:39:13 +01:00
|
|
|
if (/Date$/.test(key)) {
|
|
|
|
data[key] = val ? new Date(val) : null;
|
|
|
|
}
|
2019-09-17 22:17:40 +02:00
|
|
|
}
|
2019-08-16 23:05:39 +02:00
|
|
|
this.set(data, { silent: true });
|
|
|
|
} catch (e) {
|
|
|
|
/* failed to load model */
|
2017-02-05 21:28:43 +01:00
|
|
|
}
|
2017-02-20 23:39:13 +01:00
|
|
|
}
|
2017-02-05 21:28:43 +01:00
|
|
|
});
|
2019-09-17 21:56:58 +02:00
|
|
|
}
|
2017-02-04 19:31:26 +01:00
|
|
|
|
2019-08-18 10:17:09 +02:00
|
|
|
save() {
|
2019-09-17 23:44:17 +02:00
|
|
|
const attr = { ...this };
|
|
|
|
for (const key of Object.keys(attr)) {
|
2015-11-14 16:28:36 +01:00
|
|
|
if (key.lastIndexOf('update', 0) === 0) {
|
|
|
|
delete attr[key];
|
|
|
|
}
|
2019-09-17 23:44:17 +02:00
|
|
|
}
|
2015-12-05 14:57:43 +01:00
|
|
|
SettingsStore.save('update-info', attr);
|
2015-10-29 22:20:01 +01:00
|
|
|
}
|
2019-09-17 21:56:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateModel.defineModelProperties({
|
|
|
|
lastSuccessCheckDate: null,
|
|
|
|
lastCheckDate: null,
|
|
|
|
lastVersion: null,
|
|
|
|
lastVersionReleaseDate: null,
|
|
|
|
lastCheckError: null,
|
|
|
|
lastCheckUpdMin: null,
|
|
|
|
status: null,
|
|
|
|
updateStatus: null,
|
|
|
|
updateError: null,
|
|
|
|
updateManual: false
|
2015-10-29 22:20:01 +01:00
|
|
|
});
|
|
|
|
|
2019-09-17 21:56:58 +02:00
|
|
|
const instance = new UpdateModel();
|
2015-10-29 22:20:01 +01:00
|
|
|
|
2019-09-17 21:56:58 +02:00
|
|
|
export { instance as UpdateModel };
|