2019-09-17 21:39:06 +02:00
|
|
|
import { Collection } from 'framework/collection';
|
2019-09-15 14:16:32 +02:00
|
|
|
import { SettingsStore } from 'comp/settings/settings-store';
|
|
|
|
import { FileInfoModel } from 'models/file-info-model';
|
2015-12-06 21:32:41 +01:00
|
|
|
|
2019-09-17 21:39:06 +02:00
|
|
|
class FileInfoCollection extends Collection {
|
|
|
|
static model = FileInfoModel;
|
2015-12-06 21:32:41 +01:00
|
|
|
|
2019-08-18 10:17:09 +02:00
|
|
|
load() {
|
2020-06-01 16:53:51 +02:00
|
|
|
return SettingsStore.load('file-info').then((data) => {
|
2017-02-20 23:39:13 +01:00
|
|
|
if (data) {
|
2019-09-17 21:39:06 +02:00
|
|
|
for (const item of data) {
|
|
|
|
this.push(new FileInfoModel(item));
|
|
|
|
}
|
2017-02-20 23:39:13 +01:00
|
|
|
}
|
2017-02-05 21:28:43 +01:00
|
|
|
});
|
2019-09-17 21:39:06 +02:00
|
|
|
}
|
2017-02-04 19:31:26 +01:00
|
|
|
|
2019-08-18 10:17:09 +02:00
|
|
|
save() {
|
2019-09-17 21:39:06 +02:00
|
|
|
SettingsStore.save('file-info', this);
|
|
|
|
}
|
2015-12-07 20:07:56 +01:00
|
|
|
|
2019-08-18 10:17:09 +02:00
|
|
|
getMatch(storage, name, path) {
|
2020-06-01 16:53:51 +02:00
|
|
|
return this.find((fi) => {
|
2019-08-16 23:05:39 +02:00
|
|
|
return (
|
2019-09-17 21:39:06 +02:00
|
|
|
(fi.storage || '') === (storage || '') &&
|
|
|
|
(fi.name || '') === (name || '') &&
|
|
|
|
(fi.path || '') === (path || '')
|
2019-08-16 23:05:39 +02:00
|
|
|
);
|
2015-12-07 20:07:56 +01:00
|
|
|
});
|
2019-09-17 21:39:06 +02:00
|
|
|
}
|
2015-12-10 22:31:47 +01:00
|
|
|
|
2019-08-18 10:17:09 +02:00
|
|
|
getByName(name) {
|
2020-06-01 16:53:51 +02:00
|
|
|
return this.find((file) => file.name.toLowerCase() === name.toLowerCase());
|
2015-12-06 21:32:41 +01:00
|
|
|
}
|
2019-09-17 21:39:06 +02:00
|
|
|
}
|
2015-12-06 21:32:41 +01:00
|
|
|
|
2019-09-17 21:39:06 +02:00
|
|
|
const instance = new FileInfoCollection();
|
2015-12-06 21:32:41 +01:00
|
|
|
|
2019-09-17 21:39:06 +02:00
|
|
|
export { instance as FileInfoCollection };
|