fix(collaboration): Avoid writing spurious changes from read-only users when serialized output changes

This commit is contained in:
Tom Moor
2023-01-13 23:54:44 -05:00
parent 6b438e3467
commit 0cccd7141d

View File

@@ -86,13 +86,17 @@ export default class PersistenceExtension implements Extension {
const [, documentId] = documentName.split(".");
// Find the collaborators that have modified the document since it was last
// persisted and clear the map.
// persisted and clear the map, if there's no collaborators then we don't
// need to persist the document.
const documentCollaboratorIds = this.documentCollaboratorIds.get(
documentName
);
const collaboratorIds = documentCollaboratorIds
? Array.from(documentCollaboratorIds.values())
: [context.user?.id];
if (!documentCollaboratorIds) {
Logger.debug("multiplayer", `No changes for ${documentName}`);
return;
}
const collaboratorIds = Array.from(documentCollaboratorIds.values());
this.documentCollaboratorIds.delete(documentName);
try {