mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
fix: save created revision on realtime note destroy
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
b3eb6e4339
commit
cf02c35b49
4 changed files with 84 additions and 4 deletions
|
@ -150,6 +150,17 @@ export class RevisionsService {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates (but does not persist(!)) a new {@link Revision} for the given {@link Note}.
|
||||
* Useful if the revision is saved together with the note in one action.
|
||||
*
|
||||
* @async
|
||||
* @param note The note for which the revision should be created
|
||||
* @param newContent The new note content
|
||||
* @param yjsStateVector The yjs state vector that describes the new content
|
||||
* @return {Revision} the created revision
|
||||
* @return {undefined} if the revision couldn't be created because e.g. the content hasn't changed
|
||||
*/
|
||||
async createRevision(
|
||||
note: Note,
|
||||
newContent: string,
|
||||
|
@ -185,4 +196,27 @@ export class RevisionsService {
|
|||
tagEntities,
|
||||
) as Revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and saves a new {@link Revision} for the given {@link Note}.
|
||||
*
|
||||
* @async
|
||||
* @param note The note for which the revision should be created
|
||||
* @param newContent The new note content
|
||||
* @param yjsStateVector The yjs state vector that describes the new content
|
||||
*/
|
||||
async createAndSaveRevision(
|
||||
note: Note,
|
||||
newContent: string,
|
||||
yjsStateVector?: number[],
|
||||
): Promise<void> {
|
||||
const revision = await this.createRevision(
|
||||
note,
|
||||
newContent,
|
||||
yjsStateVector,
|
||||
);
|
||||
if (revision) {
|
||||
await this.revisionRepository.save(revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue