Remove diff summary from document history sidebar.
Cause of occassional memory leaks and downtime :(
This commit is contained in:
@@ -231,9 +231,7 @@ router.post('documents.revisions', auth(), pagination(), async ctx => {
|
||||
});
|
||||
|
||||
const data = await Promise.all(
|
||||
revisions.map((revision, index) =>
|
||||
presentRevision(ctx, revision, revisions[index + 1])
|
||||
)
|
||||
revisions.map((revision, index) => presentRevision(ctx, revision))
|
||||
);
|
||||
|
||||
ctx.body = {
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
// @flow
|
||||
import * as JSDiff from 'diff';
|
||||
import { Revision } from '../models';
|
||||
import presentUser from './user';
|
||||
|
||||
function counts(changes) {
|
||||
return changes.reduce(
|
||||
(acc, change) => {
|
||||
if (change.added) acc.added += change.value.length;
|
||||
if (change.removed) acc.removed += change.value.length;
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
added: 0,
|
||||
removed: 0,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function present(ctx: Object, revision: Revision, previous?: Revision) {
|
||||
const prev = previous ? previous.text : '';
|
||||
|
||||
function present(ctx: Object, revision: Revision) {
|
||||
return {
|
||||
id: revision.id,
|
||||
documentId: revision.documentId,
|
||||
@@ -27,7 +10,6 @@ function present(ctx: Object, revision: Revision, previous?: Revision) {
|
||||
text: revision.text,
|
||||
createdAt: revision.createdAt,
|
||||
createdBy: presentUser(ctx, revision.user),
|
||||
diff: counts(JSDiff.diffChars(prev, revision.text)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user