1 import type { CommentInterface, CommentPayload, CommentType } from '@proton/docs-shared'
2 import { ServerTime } from '@proton/docs-shared'
4 export class Comment implements CommentInterface {
7 public createTime: ServerTime,
8 public modifyTime: ServerTime,
9 public content: string,
10 public parentCommentID: string | null,
11 public author: string,
12 public comments: CommentInterface[],
13 public isPlaceholder: boolean,
14 public type: CommentType,
17 public asPayload(): CommentPayload {
20 createTime: this.createTime.serverTimestamp,
21 modifyTime: this.modifyTime.serverTimestamp,
22 content: this.content,
23 parentCommentID: this.parentCommentID,
25 comments: this.comments.map((comment) => comment.asPayload()),
26 isPlaceholder: this.isPlaceholder,
31 static fromPayload(payload: CommentPayload): CommentInterface {
34 new ServerTime(payload.createTime),
35 new ServerTime(payload.modifyTime),
37 payload.parentCommentID,
39 payload.comments.map((comment) => Comment.fromPayload(comment)),
40 payload.isPlaceholder,