diff --git a/services/web/app/src/Features/History/HistoryManager.js b/services/web/app/src/Features/History/HistoryManager.js index 1149b3e558..5ddebb5f73 100644 --- a/services/web/app/src/Features/History/HistoryManager.js +++ b/services/web/app/src/Features/History/HistoryManager.js @@ -112,7 +112,12 @@ async function injectUserDetails(data) { // service. v1 ids will be `numbers` let userIds = new Set() let v1UserIds = new Set() - for (const entry of data.diff || data.updates || []) { + const entries = Array.isArray(data.diff) + ? data.diff + : Array.isArray(data.updates) + ? data.updates + : [] + for (const entry of entries) { for (const user of (entry.meta && entry.meta.users) || []) { if (typeof user === 'string') { userIds.add(user) @@ -138,7 +143,7 @@ async function injectUserDetails(data) { for (const user of v1IdentifiedUsersArray) { users[user.overleaf.id] = _userView(user) } - for (const entry of data.diff || data.updates || []) { + for (const entry of entries) { if (entry.meta != null) { entry.meta.users = ((entry.meta && entry.meta.users) || []).map(user => { if (typeof user === 'string' || typeof user === 'number') { diff --git a/services/web/test/unit/src/History/HistoryManagerTests.js b/services/web/test/unit/src/History/HistoryManagerTests.js index c3f9eda40c..3554d15c59 100644 --- a/services/web/test/unit/src/History/HistoryManagerTests.js +++ b/services/web/test/unit/src/History/HistoryManagerTests.js @@ -195,6 +195,13 @@ describe('HistoryManager', function() { expect(diff.diff[0].meta.users).to.deep.equal([this.user1_view]) expect(diff.diff[1].meta.users).to.deep.equal([this.user2_view]) }) + + it('should handle a binary diff marker', async function() { + const diff = await this.HistoryManager.promises.injectUserDetails({ + diff: { binary: true } + }) + expect(diff.diff.binary).to.be.true + }) }) describe('with a list of updates', function() {