1 import { Comment } from './Comments'
4 CommentThreadInterface,
7 } from '@proton/docs-shared'
8 import { ServerTime } from '@proton/docs-shared'
9 import type { CommentThreadType } from '@proton/docs-shared'
11 export class CommentThread implements CommentThreadInterface {
14 public createTime: ServerTime,
15 public modifyTime: ServerTime,
16 public markID: string,
17 public comments: CommentInterface[],
18 public isPlaceholder: boolean,
19 public state: CommentThreadState,
20 public type: CommentThreadType,
23 public asPayload(): CommentThreadPayload {
26 createTime: this.createTime.serverTimestamp,
27 modifyTime: this.modifyTime.serverTimestamp,
29 comments: this.comments.map((comment) => comment.asPayload()),
30 isPlaceholder: this.isPlaceholder,
36 static fromPayload(payload: CommentThreadPayload): CommentThreadInterface {
37 return new CommentThread(
39 new ServerTime(payload.createTime),
40 new ServerTime(payload.modifyTime),
42 payload.comments.map((comment) => Comment.fromPayload(comment)),
43 payload.isPlaceholder,