fix: Revision skipped after identical previous autosave

This commit is contained in:
Tom Moor
2020-09-11 12:06:57 -07:00
parent 38d1831259
commit c298c73240
4 changed files with 72 additions and 6 deletions

View File

@@ -18,15 +18,14 @@ const serializer = new MarkdownSerializer();
export const DOCUMENT_VERSION = 2;
const createRevision = (doc, options = {}) => {
const createRevision = async (doc, options = {}) => {
// we don't create revisions for autosaves
if (options.autosave) return;
const previous = await Revision.findLatest(doc.id);
// we don't create revisions if identical to previous
if (
doc.text === doc.previous("text") &&
doc.title === doc.previous("title")
) {
if (previous && doc.text === previous.text && doc.title === previous.title) {
return;
}