bitwarden-estensione-browser/common/src/models/view/attachmentView.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
708 B
TypeScript
Raw Normal View History

2018-01-24 17:33:15 +01:00
import { View } from "./view";
import { Attachment } from "../domain/attachment";
2018-11-14 02:43:45 +01:00
import { SymmetricCryptoKey } from "../domain/symmetricCryptoKey";
2018-01-24 17:33:15 +01:00
export class AttachmentView implements View {
2019-01-25 15:30:21 +01:00
id: string = null;
url: string = null;
2019-04-14 03:20:04 +02:00
size: string = null;
2019-01-25 15:30:21 +01:00
sizeName: string = null;
fileName: string = null;
key: SymmetricCryptoKey = null;
2018-01-24 17:33:15 +01:00
2018-05-17 19:25:03 +02:00
constructor(a?: Attachment) {
if (!a) {
return;
2018-01-24 17:33:15 +01:00
}
2019-05-01 16:35:52 +02:00
2018-01-24 17:33:15 +01:00
this.id = a.id;
this.url = a.url;
this.size = a.size;
this.sizeName = a.sizeName;
2021-12-16 13:36:21 +01:00
}
2019-05-01 16:35:52 +02:00
get fileSize(): number {
try {
if (this.size != null) {
return parseInt(this.size, null);
}
} catch {
// Invalid file size.
2019-05-01 16:35:52 +02:00
}
return 0;
2021-12-16 13:36:21 +01:00
}
2018-01-24 17:33:15 +01:00
}