Skip to content

Commit e58fb0b

Browse files
committed
Changeset: Move changeset logic to a new Changeset class
1 parent e81979e commit e58fb0b

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

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

586585
// Validate all added 'author' attribs to be the same value as the current user
587-
for (const op of Changeset.deserializeOps(Changeset.unpack(changeset).ops)) {
586+
for (const op of Changeset.deserializeOps(cs.ops)) {
588587
// + can add text with attribs
589588
// = can change or add attribs
590589
// - 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
@@ -461,7 +461,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
461461
}
462462
}
463463

464-
return Changeset.checkRep(builder.toString());
464+
return builder.build().validate().toString();
465465
};
466466

467467
// export the constructor

0 commit comments

Comments
 (0)