refactor(edit): lazy-load relations

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-12-05 19:58:01 +01:00
parent 7f7886c5a7
commit 4e70044a2c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
5 changed files with 26 additions and 20 deletions

View file

@ -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;