Merge pull request #17667 from overleaf/em-history-comment-ids

Handle the commentIds property in project-history

GitOrigin-RevId: 39502a88f97e531b436a1b2d4f791c73e31bb401
This commit is contained in:
Eric Mc Sween 2024-04-02 08:24:43 -04:00 committed by Copybot
parent cdf31ed91c
commit 7a6b03cf7c
3 changed files with 27 additions and 11 deletions

View file

@ -297,16 +297,19 @@ class OperationsBuilder {
ts: new Date(update.meta.ts).toISOString(),
},
})
} else if (update.meta.tc != null) {
this.insert(op.i, {
tracking: {
} else {
const opts = {}
if (update.meta.tc != null) {
opts.tracking = {
type: 'insert',
userId: update.meta.user_id,
ts: new Date(update.meta.ts).toISOString(),
},
})
} else {
this.insert(op.i)
}
}
if (op.commentIds != null) {
opts.commentIds = op.commentIds
}
this.insert(op.i, opts)
}
}
@ -395,9 +398,10 @@ class OperationsBuilder {
* @param {string} str
* @param {object} opts
* @param {TrackingProps} [opts.tracking]
* @param {string[]} [opts.commentIds]
*/
insert(str, opts = {}) {
if (opts.tracking) {
if (opts.tracking || opts.commentIds) {
this.textOperation.push({ i: str, ...opts })
} else {
this.textOperation.push(str)

View file

@ -1,4 +1,9 @@
export type Update = TextUpdate | AddDocUpdate | AddFileUpdate | RenameUpdate | DeleteCommentUpdate
export type Update =
| TextUpdate
| AddDocUpdate
| AddFileUpdate
| RenameUpdate
| DeleteCommentUpdate
export type UpdateMeta = {
user_id: string
@ -57,6 +62,7 @@ export type InsertOp = {
u?: boolean
hpos?: number
trackedDeleteRejection?: boolean
commentIds?: string[]
}
export type DeleteOp = {

View file

@ -476,7 +476,7 @@ describe('UpdateTranslator', function () {
doc: this.doc_id,
op: [
{ p: 3, i: 'foo' },
{ p: 15, i: 'bar' },
{ p: 15, i: 'bar', commentIds: ['comment1'] },
],
v: this.version,
meta: {
@ -501,7 +501,13 @@ describe('UpdateTranslator', function () {
operations: [
{
pathname: 'main.tex',
textOperation: [3, 'foo', 9, 'bar', 8],
textOperation: [
3,
'foo',
9,
{ i: 'bar', commentIds: ['comment1'] },
8,
],
},
],
v2Authors: [this.user_id],