mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-03 00:19:57 -04:00
HistoryService: Refactor updateHistoryEntry
The function now expects a `Note` object instead of a noteId to make it more consistent with `updateHistoryEntryTimestamp`. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
99db4bc336
commit
c515569299
4 changed files with 12 additions and 8 deletions
|
@ -218,7 +218,7 @@ describe('HistoryService', () => {
|
|||
async (entry: HistoryEntry): Promise<HistoryEntry> => entry,
|
||||
);
|
||||
const updatedHistoryEntry = await service.updateHistoryEntry(
|
||||
alias,
|
||||
note,
|
||||
user,
|
||||
{
|
||||
pinStatus: true,
|
||||
|
@ -237,7 +237,7 @@ describe('HistoryService', () => {
|
|||
jest.spyOn(historyRepo, 'findOne').mockResolvedValueOnce(undefined);
|
||||
jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(note);
|
||||
await expect(
|
||||
service.updateHistoryEntry(alias, user, {
|
||||
service.updateHistoryEntry(note, user, {
|
||||
pinStatus: true,
|
||||
}),
|
||||
).rejects.toThrow(NotInDBError);
|
||||
|
|
|
@ -112,17 +112,17 @@ export class HistoryService {
|
|||
/**
|
||||
* @async
|
||||
* Update a history entry identified by the user and a note id or alias
|
||||
* @param {string} noteIdOrAlias - the note that the history entry belongs to
|
||||
* @param {Note} note - the note that the history entry belongs to
|
||||
* @param {User} user - the user that the history entry belongs to
|
||||
* @param {HistoryEntryUpdateDto} updateDto - the change that should be applied to the history entry
|
||||
* @return {HistoryEntry} the requested history entry
|
||||
*/
|
||||
async updateHistoryEntry(
|
||||
noteIdOrAlias: string,
|
||||
note: Note,
|
||||
user: User,
|
||||
updateDto: HistoryEntryUpdateDto,
|
||||
): Promise<HistoryEntry> {
|
||||
const entry = await this.getEntryByNoteIdOrAlias(noteIdOrAlias, user);
|
||||
const entry = await this.getEntryByNote(note, user);
|
||||
entry.pinStatus = updateDto.pinStatus;
|
||||
return await this.historyEntryRepository.save(entry);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue