mirror of https://github.com/keeweb/keeweb.git
37 lines
802 B
JavaScript
37 lines
802 B
JavaScript
import { Model } from 'framework/model';
|
|
import { pick } from 'util/fn';
|
|
|
|
const DefaultProperties = {
|
|
id: '',
|
|
name: '',
|
|
storage: null,
|
|
path: null,
|
|
modified: false,
|
|
editState: null,
|
|
rev: null,
|
|
syncDate: null,
|
|
openDate: null,
|
|
keyFileName: null,
|
|
keyFileHash: null,
|
|
keyFilePath: null,
|
|
opts: null,
|
|
backup: null,
|
|
fingerprint: null
|
|
};
|
|
|
|
class FileInfoModel extends Model {
|
|
constructor(data) {
|
|
data = pick({ ...data }, Object.keys(DefaultProperties));
|
|
for (const [key, val] of Object.entries(data)) {
|
|
if (/Date$/.test(key)) {
|
|
data[key] = val ? new Date(val) : null;
|
|
}
|
|
}
|
|
super(data);
|
|
}
|
|
}
|
|
|
|
FileInfoModel.defineModelProperties(DefaultProperties);
|
|
|
|
export { FileInfoModel };
|