Remove client-side isLoggedIn value
[ProtonMail-WebClient.git] / packages / docs-core / lib / Models / CommentThread.ts
blob7048ccfa28aec738bf8151da7496bb22adcc6bb1
1 import { Comment } from './Comments'
2 import type {
3   CommentThreadPayload,
4   CommentThreadInterface,
5   CommentThreadState,
6   CommentInterface,
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 {
12   constructor(
13     public id: string,
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,
21   ) {}
23   public asPayload(): CommentThreadPayload {
24     return {
25       id: this.id,
26       createTime: this.createTime.serverTimestamp,
27       modifyTime: this.modifyTime.serverTimestamp,
28       markID: this.markID,
29       comments: this.comments.map((comment) => comment.asPayload()),
30       isPlaceholder: this.isPlaceholder,
31       state: this.state,
32       type: this.type,
33     }
34   }
36   static fromPayload(payload: CommentThreadPayload): CommentThreadInterface {
37     return new CommentThread(
38       payload.id,
39       new ServerTime(payload.createTime),
40       new ServerTime(payload.modifyTime),
41       payload.markID,
42       payload.comments.map((comment) => Comment.fromPayload(comment)),
43       payload.isPlaceholder,
44       payload.state,
45       payload.type,
46     )
47   }