mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 01:35:18 -04:00
refactor(edit): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
c5c7307552
commit
e73bd7c030
5 changed files with 26 additions and 20 deletions
|
@ -713,18 +713,18 @@ describe('NotesService', () => {
|
|||
const revisions = await note.revisions;
|
||||
revisions[0].edits = [
|
||||
{
|
||||
revisions: revisions,
|
||||
revisions: Promise.resolve(revisions),
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452000),
|
||||
author: author,
|
||||
author: Promise.resolve(author),
|
||||
} as Edit,
|
||||
{
|
||||
revisions: revisions,
|
||||
revisions: Promise.resolve(revisions),
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452001),
|
||||
author: author,
|
||||
author: Promise.resolve(author),
|
||||
} as Edit,
|
||||
];
|
||||
revisions[0].createdAt = new Date(1549312452000);
|
||||
|
@ -812,18 +812,18 @@ describe('NotesService', () => {
|
|||
const revisions = await note.revisions;
|
||||
revisions[0].edits = [
|
||||
{
|
||||
revisions: revisions,
|
||||
revisions: Promise.resolve(revisions),
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452000),
|
||||
author: author,
|
||||
author: Promise.resolve(author),
|
||||
} as Edit,
|
||||
{
|
||||
revisions: revisions,
|
||||
revisions: Promise.resolve(revisions),
|
||||
startPos: 0,
|
||||
endPos: 1,
|
||||
updatedAt: new Date(1549312452001),
|
||||
author: author,
|
||||
author: Promise.resolve(author),
|
||||
} as Edit,
|
||||
];
|
||||
revisions[0].createdAt = new Date(1549312452000);
|
||||
|
|
|
@ -343,9 +343,11 @@ export class NotesService {
|
|||
if (lastRevision && lastRevision.edits) {
|
||||
// Sort the last Revisions Edits by their updatedAt Date to get the latest one
|
||||
// the user of that Edit is the updateUser
|
||||
return await lastRevision.edits.sort(
|
||||
(a, b) => b.updatedAt.getTime() - a.updatedAt.getTime(),
|
||||
)[0].author.user;
|
||||
return await (
|
||||
await lastRevision.edits.sort(
|
||||
(a, b) => b.updatedAt.getTime() - a.updatedAt.getTime(),
|
||||
)[0].author
|
||||
).user;
|
||||
}
|
||||
// If there are no Edits, the owner is the updateUser
|
||||
return await note.owner;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue