1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 01:33:33 +00:00
Files
browser/libs/common/src/models/domain/folder.ts
Matt Gibson 5339344630 PS-1133 Feature/mv3 browser observable memory caching (#3245)
* Create sessions sync structure

* Add observing to session-syncer

* Do not run syncer logic in decorator tests

* Extract test constants

* Change Observables to BehaviorSubject

* Move sendMessage to static method in BrowserApi

* Implement session sync

* only watch in manifest v3

* Use session sync on folder service

* Add array observable sync

* Bypass cache on update from message

* Create feature and dev flags for browser

* Protect development-only methods with decorator

* Improve todo comments for long-term residency

* Use class properties in init

* Do not reuse mocks

* Use json (de)serialization patterns

* Fix failing session storage in dev environment

* Split up complex EncString constructor

* Default false for decrypted session storage

* Try removing hydrate EncString method

* PR review

* PR test review
2022-08-16 07:05:03 -05:00

48 lines
1000 B
TypeScript

import { Jsonify } from "type-fest";
import { FolderData } from "../data/folderData";
import { FolderView } from "../view/folderView";
import Domain from "./domainBase";
import { EncString } from "./encString";
export class Folder extends Domain {
id: string;
name: EncString;
revisionDate: Date;
constructor(obj?: FolderData) {
super();
if (obj == null) {
return;
}
this.buildDomainModel(
this,
obj,
{
id: null,
name: null,
},
["id"]
);
this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null;
}
decrypt(): Promise<FolderView> {
return this.decryptObj(
new FolderView(this),
{
name: null,
},
null
);
}
static fromJSON(obj: Jsonify<Folder>) {
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
return Object.assign(new Folder(), obj, { name: EncString.fromJSON(obj.name), revisionDate });
}
}