diff --git a/services/project-history/app/js/SummarizedUpdatesManager.js b/services/project-history/app/js/SummarizedUpdatesManager.js index c94074136b..b6f409f350 100644 --- a/services/project-history/app/js/SummarizedUpdatesManager.js +++ b/services/project-history/app/js/SummarizedUpdatesManager.js @@ -189,10 +189,10 @@ function _summarizeUpdates(updates, labels, existingSummarizedUpdates, toV) { toV = update.v + 1 } - // Skip empty updates (only record their version). Empty updates are - // updates that only contain comment operations. We don't have a UI for + // Skip empty and history-resync updates (only record their version). + // Empty updates are updates that only contain comment operations. We don't have a UI for // these yet. - if (isUpdateEmpty(update)) { + if (isUpdateEmpty(update) || isHistoryResyncUpdate(update)) { continue } @@ -282,11 +282,8 @@ function _shouldMergeUpdate(update, summarizedUpdate, labels) { const updateHasFileOps = update.project_ops.length > 0 const summarizedUpdateHasTextOps = summarizedUpdate.pathnames.size > 0 const summarizedUpdateHasFileOps = summarizedUpdate.project_ops.length > 0 - const isHistoryResync = - update.meta.origin && - ['history-resync', 'history-migration'].includes(update.meta.origin.kind) if ( - !isHistoryResync && + !isHistoryResyncUpdate(update) && ((updateHasTextOps && summarizedUpdateHasFileOps) || (updateHasFileOps && summarizedUpdateHasTextOps)) ) { @@ -346,3 +343,10 @@ function _mergeUpdate(update, summarizedUpdate) { function isUpdateEmpty(update) { return update.project_ops.length === 0 && update.pathnames.length === 0 } + +function isHistoryResyncUpdate(update) { + return ( + update.meta.origin?.kind === 'history-resync' || + update.meta.origin?.kind === 'history-migration' + ) +} diff --git a/services/project-history/test/unit/js/SummarizedUpdatesManager/SummarizedUpdatesManagerTests.js b/services/project-history/test/unit/js/SummarizedUpdatesManager/SummarizedUpdatesManagerTests.js index 3cd08426b0..a735edcc39 100644 --- a/services/project-history/test/unit/js/SummarizedUpdatesManager/SummarizedUpdatesManagerTests.js +++ b/services/project-history/test/unit/js/SummarizedUpdatesManager/SummarizedUpdatesManagerTests.js @@ -595,12 +595,12 @@ describe('SummarizedUpdatesManager', function () { makeUpdate({ startTs: 20, v: 3, - origin: { kind: 'history-resync' }, + origin: { kind: 'origin-a' }, }), makeUpdate({ startTs: 30, v: 4, - origin: { kind: 'history-resync' }, + origin: { kind: 'origin-a' }, }), makeUpdate({ startTs: 40, v: 5 }), makeUpdate({ startTs: 50, v: 6 }), @@ -617,7 +617,7 @@ describe('SummarizedUpdatesManager', function () { endTs: 40, fromV: 3, toV: 5, - origin: { kind: 'history-resync' }, + origin: { kind: 'origin-a' }, }), makeSummary({ startTs: 0, endTs: 20, fromV: 1, toV: 3 }), ] @@ -687,13 +687,7 @@ describe('SummarizedUpdatesManager', function () { describe('history resync updates', function () { setupChunks([ [ - makeUpdate({ - startTs: 0, - v: 1, - origin: { kind: 'history-resync' }, - projectOps: [{ add: { pathname: 'file1.tex' } }], - pathnames: [], - }), + makeUpdate({ startTs: 0, v: 1 }), makeUpdate({ startTs: 20, v: 2, @@ -709,47 +703,13 @@ describe('SummarizedUpdatesManager', function () { v: 3, origin: { kind: 'history-resync' }, projectOps: [{ add: { pathname: 'file4.tex' } }], - pathnames: [], }), - makeUpdate({ - startTs: 60, - v: 4, - origin: { kind: 'history-resync' }, - projectOps: [], - pathnames: ['file1.tex', 'file2.tex', 'file5.tex'], - }), - makeUpdate({ - startTs: 80, - v: 5, - origin: { kind: 'history-resync' }, - projectOps: [], - pathnames: ['file4.tex'], - }), - makeUpdate({ startTs: 100, v: 6, pathnames: ['file1.tex'] }), + makeUpdate({ startTs: 60, v: 4 }), + makeUpdate({ startTs: 80, v: 5 }), ], ]) - expectSummaries('should merge creates and edits', {}, [ - makeSummary({ - startTs: 100, - endTs: 110, - fromV: 6, - toV: 7, - pathnames: ['file1.tex'], - }), - makeSummary({ - startTs: 0, - endTs: 90, - fromV: 1, - toV: 6, - origin: { kind: 'history-resync' }, - pathnames: ['file5.tex'], - projectOps: [ - { add: { pathname: 'file4.tex' }, atV: 3 }, - { add: { pathname: 'file2.tex' }, atV: 2 }, - { add: { pathname: 'file3.tex' }, atV: 2 }, - { add: { pathname: 'file1.tex' }, atV: 1 }, - ], - }), + expectSummaries('should skip history-resync updates', {}, [ + makeSummary({ startTs: 0, endTs: 90, fromV: 1, toV: 6 }), ]) }) })