1 import type { DocumentMetaInterface } from '@proton/docs-shared'
2 import type { NodeMeta } from '@proton/drive-store/lib'
3 import type { PublicNodeMetaWithResolvedVolumeID } from '@proton/drive-store/lib/interface'
4 import { isPublicNodeMeta } from '@proton/drive-store/lib/interface'
6 export class DocumentMeta implements DocumentMetaInterface {
8 public nodeMeta: NodeMeta | PublicNodeMetaWithResolvedVolumeID,
9 public commitIds: string[],
10 public createTime: number,
11 public modifyTime: number,
15 public isEqual(other: DocumentMeta): boolean {
16 if (isPublicNodeMeta(this.nodeMeta) !== isPublicNodeMeta(other.nodeMeta)) {
20 if (isPublicNodeMeta(this.nodeMeta) && isPublicNodeMeta(other.nodeMeta)) {
21 return this.nodeMeta.linkId === other.nodeMeta.linkId && this.nodeMeta.token === other.nodeMeta.token
22 } else if (!isPublicNodeMeta(this.nodeMeta) && !isPublicNodeMeta(other.nodeMeta)) {
23 return this.nodeMeta.volumeId === other.nodeMeta.volumeId && this.nodeMeta.linkId === other.nodeMeta.linkId
29 copyWithNewValues(newValues: Partial<DocumentMetaInterface>): DocumentMetaInterface {
30 return new DocumentMeta(
31 newValues.nodeMeta ?? this.nodeMeta,
32 newValues.commitIds ?? this.commitIds,
33 newValues.createTime ?? this.createTime,
34 newValues.modifyTime ?? this.modifyTime,
35 newValues.name ?? this.name,
39 latestCommitId(): string | undefined {
40 return this.commitIds[this.commitIds.length - 1]
43 public get uniqueIdentifier(): string {
44 return this.nodeMeta.linkId