Skip to content

Commit 1a7106a

Browse files
committed
Changeset: Move changeset logic to a new Changeset class
1 parent 236b7f1 commit 1a7106a

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
@@ -571,8 +571,7 @@ const handleUserChanges = async (socket, message) => {
571571
// create the changeset
572572
try {
573573
try {
574-
// Verify that the changeset has valid syntax and is in canonical form
575-
Changeset.checkRep(changeset);
574+
const cs = Changeset.unpack(changeset).validate();
576575

577576
// Verify that the attribute indexes used in the changeset are all
578577
// defined in the accompanying attribute pool.
@@ -583,7 +582,7 @@ const handleUserChanges = async (socket, message) => {
583582
});
584583

585584
// Validate all added 'author' attribs to be the same value as the current user
586-
for (const op of Changeset.deserializeOps(Changeset.unpack(changeset).ops)) {
585+
for (const op of Changeset.deserializeOps(cs.ops)) {
587586
// + can add text with attribs
588587
// = can change or add attribs
589588
// - 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)