Skip to content

Commit

Permalink
feat(pro): (incomplete) integrate track changes interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhyc committed Feb 23, 2024
1 parent 8f3dc02 commit d382944
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 75 deletions.
6 changes: 6 additions & 0 deletions src/api/extendedBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface DocumentReviewSchema {

export interface DocumentReviewChangeSchema extends DocumentReviewSchema {
op: {p:number, i?:string, d?:string},
associate?: DocumentReviewChangeSchema, // to be filled in via API call
}

export interface DocumentReviewCommentSchema extends DocumentReviewSchema {
Expand Down Expand Up @@ -119,6 +120,11 @@ export class ExtendedBaseAPI extends BaseAPI {
return await this.request('POST', `project/${project_id}/thread/${thread_id}/messages/${message_id}/edit`, {content});
}

async toggleTrackChanges(identity: Identity, project_id: string, on_for: boolean | {[userId:string]: boolean}) {
this.setIdentity(identity);
return await this.request('POST', `project/${project_id}/track_changes`, {on_for});
}

async acceptTrackChanges(identity: Identity, project_id: string, doc_id: string, change_ids: string[]) {
this.setIdentity(identity);
return await this.request('POST', `project/${project_id}/doc/${doc_id}/changes/accept`, {change_ids});
Expand Down
6 changes: 6 additions & 0 deletions src/api/socketio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface EventsHandler {
onCommentThreadMessageCreated?: (threadId:string, message:CommentThreadMessageSchema) => void,
onCommentThreadMessageEdited?: (threadId:string, messageId:string, content:string) => void,
onCommentThreadMessageDeleted?: (threadId:string, messageId:string) => void,
onToggleTrackChanges?: (enabling:boolean | {[userId:string]: boolean}) => void,
onAcceptTrackChanges?: (docId:string, tcIds: string[]) => void,
}

Expand Down Expand Up @@ -302,6 +303,11 @@ export class SocketIOAPI {
handler(threadId, messageId);
});
break;
case handlers.onToggleTrackChanges:
this.socket.on('toggle-track-changes', (enabling:boolean | {[userId:string]: boolean}) => {
handler(enabling);
});
break;
case handlers.onAcceptTrackChanges:
this.socket.on('accept-changes', (docId:string, tcIds: string[]) => {
handler(docId, tcIds);
Expand Down
Loading

0 comments on commit d382944

Please sign in to comment.