Skip to content

Commit 410d02e

Browse files
committed
Changeset: Move changeset logic to a new Changeset class
1 parent a5ba53f commit 410d02e

File tree

6 files changed

+181
-125
lines changed

6 files changed

+181
-125
lines changed

src/node/handler/PadMessageHandler.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,10 @@ const handleUserChanges = async (socket, message) => {
582582
const wireApool = (new AttributePool()).fromJsonable(apool);
583583
const pad = await padManager.getPad(thisSession.padId);
584584

585-
// Verify that the changeset has valid syntax and is in canonical form
586-
Changeset.checkRep(changeset);
585+
const cs = Changeset.unpack(changeset).validate();
587586

588587
// Validate all added 'author' attribs to be the same value as the current user
589-
for (const op of Changeset.deserializeOps(Changeset.unpack(changeset).ops)) {
588+
for (const op of Changeset.deserializeOps(cs.ops)) {
590589
// + can add text with attribs
591590
// = can change or add attribs
592591
// - can have attribs, but they are discarded and don't show up in the attribs -

src/node/utils/padDiff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
438438
}
439439
}
440440

441-
return Changeset.checkRep(builder.toString());
441+
return builder.build().validate().toString();
442442
};
443443

444444
// export the constructor

0 commit comments

Comments
 (0)