Skip to content

Commit 5f0ec2c

Browse files
committed
Changeset: Move changeset logic to a new Changeset class
1 parent f97c020 commit 5f0ec2c

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
@@ -574,8 +574,7 @@ const handleUserChanges = async (socket, message) => {
574574
// create the changeset
575575
try {
576576
try {
577-
// Verify that the changeset has valid syntax and is in canonical form
578-
Changeset.checkRep(changeset);
577+
const cs = Changeset.unpack(changeset).validate();
579578

580579
// Verify that the attribute indexes used in the changeset are all
581580
// defined in the accompanying attribute pool.
@@ -586,7 +585,7 @@ const handleUserChanges = async (socket, message) => {
586585
});
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
@@ -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)