mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 09:04:44 -04:00
HistoryService: toHistoryEntryDto does not need to be async
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
bfa5f0dfc6
commit
616f963b8e
3 changed files with 5 additions and 7 deletions
|
@ -55,9 +55,7 @@ export class MeController {
|
||||||
async getUserHistory(@Req() req: Request): Promise<HistoryEntryDto[]> {
|
async getUserHistory(@Req() req: Request): Promise<HistoryEntryDto[]> {
|
||||||
const foundEntries = await this.historyService.getEntriesByUser(req.user);
|
const foundEntries = await this.historyService.getEntriesByUser(req.user);
|
||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
foundEntries.map(
|
foundEntries.map((entry) => this.historyService.toHistoryEntryDto(entry)),
|
||||||
async (entry) => await this.historyService.toHistoryEntryDto(entry),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +68,7 @@ export class MeController {
|
||||||
): Promise<HistoryEntryDto> {
|
): Promise<HistoryEntryDto> {
|
||||||
// ToDo: Check if user is allowed to pin this history entry
|
// ToDo: Check if user is allowed to pin this history entry
|
||||||
try {
|
try {
|
||||||
return await this.historyService.toHistoryEntryDto(
|
return this.historyService.toHistoryEntryDto(
|
||||||
await this.historyService.updateHistoryEntry(
|
await this.historyService.updateHistoryEntry(
|
||||||
note,
|
note,
|
||||||
req.user,
|
req.user,
|
||||||
|
|
|
@ -248,7 +248,7 @@ describe('HistoryService', () => {
|
||||||
const historyEntry = HistoryEntry.create(user, note);
|
const historyEntry = HistoryEntry.create(user, note);
|
||||||
historyEntry.pinStatus = true;
|
historyEntry.pinStatus = true;
|
||||||
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
||||||
const historyEntryDto = await service.toHistoryEntryDto(historyEntry);
|
const historyEntryDto = service.toHistoryEntryDto(historyEntry);
|
||||||
expect(historyEntryDto.pinStatus).toEqual(true);
|
expect(historyEntryDto.pinStatus).toEqual(true);
|
||||||
expect(historyEntryDto.identifier).toEqual(alias);
|
expect(historyEntryDto.identifier).toEqual(alias);
|
||||||
expect(historyEntryDto.tags).toEqual(tags);
|
expect(historyEntryDto.tags).toEqual(tags);
|
||||||
|
@ -271,7 +271,7 @@ describe('HistoryService', () => {
|
||||||
const historyEntry = HistoryEntry.create(user, note);
|
const historyEntry = HistoryEntry.create(user, note);
|
||||||
historyEntry.pinStatus = true;
|
historyEntry.pinStatus = true;
|
||||||
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
||||||
const historyEntryDto = await service.toHistoryEntryDto(historyEntry);
|
const historyEntryDto = service.toHistoryEntryDto(historyEntry);
|
||||||
expect(historyEntryDto.pinStatus).toEqual(true);
|
expect(historyEntryDto.pinStatus).toEqual(true);
|
||||||
expect(historyEntryDto.identifier).toEqual(id);
|
expect(historyEntryDto.identifier).toEqual(id);
|
||||||
expect(historyEntryDto.tags).toEqual(tags);
|
expect(historyEntryDto.tags).toEqual(tags);
|
||||||
|
|
|
@ -93,7 +93,7 @@ export class HistoryService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async toHistoryEntryDto(entry: HistoryEntry): Promise<HistoryEntryDto> {
|
toHistoryEntryDto(entry: HistoryEntry): HistoryEntryDto {
|
||||||
return {
|
return {
|
||||||
identifier: entry.note.alias ? entry.note.alias : entry.note.id,
|
identifier: entry.note.alias ? entry.note.alias : entry.note.id,
|
||||||
lastVisited: entry.updatedAt,
|
lastVisited: entry.updatedAt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue