Skip to content

Commit 7b1aaeb

Browse files
committed
Changeset: Move changeset logic to a new Changeset class
1 parent fe6dc48 commit 7b1aaeb

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
@@ -569,8 +569,7 @@ const handleUserChanges = async (socket, message) => {
569569
// create the changeset
570570
try {
571571
try {
572-
// Verify that the changeset has valid syntax and is in canonical form
573-
Changeset.checkRep(changeset);
572+
const cs = Changeset.unpack(changeset).validate();
574573

575574
// Verify that the attribute indexes used in the changeset are all
576575
// defined in the accompanying attribute pool.
@@ -581,7 +580,7 @@ const handleUserChanges = async (socket, message) => {
581580
});
582581

583582
// Validate all added 'author' attribs to be the same value as the current user
584-
for (const op of Changeset.deserializeOps(Changeset.unpack(changeset).ops)) {
583+
for (const op of Changeset.deserializeOps(cs.ops)) {
585584
// + can add text with attribs
586585
// = can change or add attribs
587586
// - 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
@@ -455,7 +455,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
455455
}
456456
}
457457

458-
return Changeset.checkRep(builder.toString());
458+
return builder.build().validate().toString();
459459
};
460460

461461
// export the constructor

0 commit comments

Comments
 (0)