mirror of
https://github.com/bitwarden/browser
synced 2026-02-18 18:33:50 +00:00
* PM-28183 implemented new sends filter and search design * PM-28183 resolved table issue fallout from merge conflict * PM-28183 resolved browser paste url issue * PM-28183 put new feature behind feature flag * PM-28183 resolved feature flag * PM-28183 resolved type-safe approach pr comment * PM-28183 resolved DesktopSendUIRefresh feature flag is enabled. pr comment * PM-28183 restored SendUIRefresh * PM-28183 resolved query parameter subscription pr comment * PM-28183 resolved pr comment re enum like objects * PM-28183 resolved remove enum like objects pr comment * PM-28183 resolved pr comment re defining filteredSends member variable * PM-28183 resolved pr comment re Code Duplication in syncCompleted Handler * PM-28183 resolved pr comment re Floating Promise * PM-28183 restored feature flag * PM-28183 resolved pr comment re Dual Binding Pattern * PM28183 resolved options cell button pr comment * PM 28183 resolved pr comment re Incorrect CSS Class - Breaking Layout * PM 28183 resolved pr comment re uery Param Update Causes Redundant Filter Application * PM-28183 resolved lint issues * PM 28183 resolved lint issues * PM-28183 resolved type issue with import * PM-28183 resolved import in failling test * chore: rerun web build * PM-28183 resolved build issues * PM-28183 resolved build issues * PM-28183 resolved lint issues
98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { View } from "../../../../models/view/view";
|
|
import { Utils } from "../../../../platform/misc/utils";
|
|
import { SymmetricCryptoKey } from "../../../../platform/models/domain/symmetric-crypto-key";
|
|
import { DeepJsonify } from "../../../../types/deep-jsonify";
|
|
import { SendType } from "../../types/send-type";
|
|
import { Send } from "../domain/send";
|
|
|
|
import { SendFileView } from "./send-file.view";
|
|
import { SendTextView } from "./send-text.view";
|
|
|
|
export class SendView implements View {
|
|
id: string = null;
|
|
accessId: string = null;
|
|
name: string = null;
|
|
notes: string = null;
|
|
key: Uint8Array;
|
|
cryptoKey: SymmetricCryptoKey;
|
|
type: SendType = null;
|
|
text = new SendTextView();
|
|
file = new SendFileView();
|
|
maxAccessCount?: number = null;
|
|
accessCount = 0;
|
|
revisionDate: Date = null;
|
|
deletionDate: Date = null;
|
|
expirationDate: Date = null;
|
|
password: string = null;
|
|
emails: string[] = [];
|
|
disabled = false;
|
|
hideEmail = false;
|
|
|
|
constructor(s?: Send) {
|
|
if (!s) {
|
|
return;
|
|
}
|
|
|
|
this.id = s.id;
|
|
this.accessId = s.accessId;
|
|
this.type = s.type;
|
|
this.maxAccessCount = s.maxAccessCount;
|
|
this.accessCount = s.accessCount;
|
|
this.revisionDate = s.revisionDate;
|
|
this.deletionDate = s.deletionDate;
|
|
this.expirationDate = s.expirationDate;
|
|
this.disabled = s.disabled;
|
|
this.password = s.password;
|
|
this.hideEmail = s.hideEmail;
|
|
}
|
|
|
|
get urlB64Key(): string {
|
|
return Utils.fromBufferToUrlB64(this.key);
|
|
}
|
|
|
|
get maxAccessCountReached(): boolean {
|
|
if (this.maxAccessCount == null) {
|
|
return false;
|
|
}
|
|
return this.accessCount >= this.maxAccessCount;
|
|
}
|
|
|
|
get expired(): boolean {
|
|
if (this.expirationDate == null) {
|
|
return false;
|
|
}
|
|
return this.expirationDate <= new Date();
|
|
}
|
|
|
|
get pendingDelete(): boolean {
|
|
return this.deletionDate <= new Date();
|
|
}
|
|
|
|
toJSON() {
|
|
return Utils.merge(
|
|
{ ...this },
|
|
{
|
|
key: Utils.fromBufferToB64(this.key),
|
|
},
|
|
);
|
|
}
|
|
|
|
static fromJSON(json: DeepJsonify<SendView>) {
|
|
if (json == null) {
|
|
return null;
|
|
}
|
|
|
|
return Object.assign(new SendView(), json, {
|
|
key: Utils.fromB64ToArray(json.key),
|
|
cryptoKey: SymmetricCryptoKey.fromJSON(json.cryptoKey),
|
|
text: SendTextView.fromJSON(json.text),
|
|
file: SendFileView.fromJSON(json.file),
|
|
revisionDate: json.revisionDate == null ? null : new Date(json.revisionDate),
|
|
deletionDate: json.deletionDate == null ? null : new Date(json.deletionDate),
|
|
expirationDate: json.expirationDate == null ? null : new Date(json.expirationDate),
|
|
});
|
|
}
|
|
}
|