Skip to content

Commit

Permalink
Swap to nullableFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Dec 2, 2022
1 parent 4677176 commit bb46b75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions libs/common/src/models/domain/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class Folder implements DecryptableDomain {
}

static fromJSON(obj: Jsonify<Folder>) {
const revisionDate = nullableFactory(Date, obj.revisionDate);
return Object.assign(new Folder(), obj, { name: EncString.fromJSON(obj.name), revisionDate });
return Object.assign(new Folder(), obj, {
name: nullableFactory(EncString, obj.name),
revisionDate: nullableFactory(Date, obj.revisionDate),
});
}
}
7 changes: 4 additions & 3 deletions libs/common/src/models/view/folder.view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Jsonify } from "type-fest";

import { EncryptService } from "../../abstractions/encrypt.service";
import { Encryptable } from "../../interfaces/crypto.interface";
import { Encryptable, nullableFactory } from "../../interfaces/crypto.interface";
import { Folder } from "../domain/folder";
import { SymmetricCryptoKey } from "../domain/symmetric-crypto-key";
import { ITreeNodeObject } from "../domain/tree-node";
Expand Down Expand Up @@ -36,7 +36,8 @@ export class FolderView implements ITreeNodeObject, Encryptable<Folder> {
}

static fromJSON(obj: Jsonify<FolderView>) {
const revisionDate = obj.revisionDate == null ? null : new Date(obj.revisionDate);
return Object.assign(new FolderView(), obj, { revisionDate });
return Object.assign(new FolderView(), obj, {
revisionDate: nullableFactory(Date, obj.revisionDate),
});
}
}

0 comments on commit bb46b75

Please sign in to comment.