From b37b2d10477d6b641af604c812157b4cbfe309a1 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Wed, 24 Feb 2021 21:19:48 +0100 Subject: [PATCH] HistoryService: toHistoryEntryDto does not need to be async Signed-off-by: David Mehren --- src/api/public/me/me.controller.ts | 6 ++---- src/history/history.service.spec.ts | 4 ++-- src/history/history.service.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api/public/me/me.controller.ts b/src/api/public/me/me.controller.ts index 0ba65b013..f68851a5b 100644 --- a/src/api/public/me/me.controller.ts +++ b/src/api/public/me/me.controller.ts @@ -55,9 +55,7 @@ export class MeController { async getUserHistory(@Req() req: Request): Promise { const foundEntries = await this.historyService.getEntriesByUser(req.user); return await Promise.all( - foundEntries.map( - async (entry) => await this.historyService.toHistoryEntryDto(entry), - ), + foundEntries.map((entry) => this.historyService.toHistoryEntryDto(entry)), ); } @@ -70,7 +68,7 @@ export class MeController { ): Promise { // ToDo: Check if user is allowed to pin this history entry try { - return await this.historyService.toHistoryEntryDto( + return this.historyService.toHistoryEntryDto( await this.historyService.updateHistoryEntry( note, req.user, diff --git a/src/history/history.service.spec.ts b/src/history/history.service.spec.ts index af4613dc1..bea7a67cd 100644 --- a/src/history/history.service.spec.ts +++ b/src/history/history.service.spec.ts @@ -248,7 +248,7 @@ describe('HistoryService', () => { const historyEntry = HistoryEntry.create(user, note); historyEntry.pinStatus = true; jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note); - const historyEntryDto = await service.toHistoryEntryDto(historyEntry); + const historyEntryDto = service.toHistoryEntryDto(historyEntry); expect(historyEntryDto.pinStatus).toEqual(true); expect(historyEntryDto.identifier).toEqual(alias); expect(historyEntryDto.tags).toEqual(tags); @@ -271,7 +271,7 @@ describe('HistoryService', () => { const historyEntry = HistoryEntry.create(user, note); historyEntry.pinStatus = true; jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note); - const historyEntryDto = await service.toHistoryEntryDto(historyEntry); + const historyEntryDto = service.toHistoryEntryDto(historyEntry); expect(historyEntryDto.pinStatus).toEqual(true); expect(historyEntryDto.identifier).toEqual(id); expect(historyEntryDto.tags).toEqual(tags); diff --git a/src/history/history.service.ts b/src/history/history.service.ts index 1d3d908ac..aef7bc389 100644 --- a/src/history/history.service.ts +++ b/src/history/history.service.ts @@ -93,7 +93,7 @@ export class HistoryService { return; } - async toHistoryEntryDto(entry: HistoryEntry): Promise { + toHistoryEntryDto(entry: HistoryEntry): HistoryEntryDto { return { identifier: entry.note.alias ? entry.note.alias : entry.note.id, lastVisited: entry.updatedAt,