mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 03:33:58 -05:00
RevisionsService: Refactor getFirst/LastRevision
The functions now expect a `Note` object instead of a noteId to make it more consistent with other functions. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
fe26f1689c
commit
5ecb0c0694
2 changed files with 8 additions and 8 deletions
|
@ -129,7 +129,7 @@ export class NotesService {
|
|||
* @return {Revision} the first revision of the note
|
||||
*/
|
||||
async getLatestRevision(note: Note): Promise<Revision> {
|
||||
return await this.revisionsService.getLatestRevision(note.id);
|
||||
return await this.revisionsService.getLatestRevision(note);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@ export class NotesService {
|
|||
* @return {Revision} the last revision of the note
|
||||
*/
|
||||
async getFirstRevision(note: Note): Promise<Revision> {
|
||||
return await this.revisionsService.getFirstRevision(note.id);
|
||||
return await this.revisionsService.getFirstRevision(note);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,10 +49,10 @@ export class RevisionsService {
|
|||
return revision;
|
||||
}
|
||||
|
||||
async getLatestRevision(noteId: string): Promise<Revision> {
|
||||
async getLatestRevision(note: Note): Promise<Revision> {
|
||||
const revision = await this.revisionRepository.findOne({
|
||||
where: {
|
||||
note: noteId,
|
||||
note: note,
|
||||
},
|
||||
order: {
|
||||
createdAt: 'DESC',
|
||||
|
@ -60,22 +60,22 @@ export class RevisionsService {
|
|||
},
|
||||
});
|
||||
if (revision === undefined) {
|
||||
throw new NotInDBError(`Revision for note ${noteId} not found.`);
|
||||
throw new NotInDBError(`Revision for note ${note.id} not found.`);
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
|
||||
async getFirstRevision(noteId: string): Promise<Revision> {
|
||||
async getFirstRevision(note: Note): Promise<Revision> {
|
||||
const revision = await this.revisionRepository.findOne({
|
||||
where: {
|
||||
note: noteId,
|
||||
note: note,
|
||||
},
|
||||
order: {
|
||||
createdAt: 'ASC',
|
||||
},
|
||||
});
|
||||
if (revision === undefined) {
|
||||
throw new NotInDBError(`Revision for note ${noteId} not found.`);
|
||||
throw new NotInDBError(`Revision for note ${note.id} not found.`);
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue