Skip to content

Commit

Permalink
Remove createdAtMapByActor in EditReverseOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 committed Sep 25, 2023
1 parent 5f9263f commit 5716e26
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 81 deletions.
17 changes: 0 additions & 17 deletions src/api/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,6 @@ function toOperation(operation: Operation): PbOperation {
pbEditReverseOperation.setDeletedIdsList(pbDeletedIDs);
pbEditReverseOperation.setInsertedIdsList(pbInsertedIDs);

const pbCreatedAtMapByActor =
pbEditReverseOperation.getCreatedAtMapByActorMap();
if (editReverseOperation.getMaxCreatedAtMapByActor()) {
for (const [
key,
value,
] of editReverseOperation.getMaxCreatedAtMapByActor()!) {
pbCreatedAtMapByActor.set(key, toTimeTicket(value)!);
}
}
const pbAttributes = pbEditReverseOperation.getAttributesMap();
for (const [key, value] of editReverseOperation.getAttributes()) {
pbAttributes.set(key, value);
Expand Down Expand Up @@ -1118,12 +1108,6 @@ function fromOperations(pbOperations: Array<PbOperation>): Array<Operation> {
});
} else if (pbOperation.hasEditReverse()) {
const pbEditReverseOperation = pbOperation.getEditReverse();
const createdAtMapByActor = new Map();
pbEditReverseOperation!
.getCreatedAtMapByActorMap()
.forEach((value, key) => {
createdAtMapByActor.set(key, fromTimeTicket(value));
});
const attributes = new Map();
pbEditReverseOperation!.getAttributesMap().forEach((value, key) => {
attributes.set(key, value);
Expand All @@ -1148,7 +1132,6 @@ function fromOperations(pbOperations: Array<PbOperation>): Array<Operation> {
insertedIDs,
attributes,
executedAt: fromTimeTicket(pbEditReverseOperation!.getExecutedAt())!,
maxCreatedAtMapByActor: createdAtMapByActor,
});
} else if (pbOperation.hasStyle()) {
const pbStyleOperation = pbOperation.getStyle();
Expand Down
5 changes: 2 additions & 3 deletions src/api/yorkie/v1/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ message Operation {
TimeTicket parent_created_at = 1;
repeated TextNodePos deleted_ids = 2;
repeated TextNodePos inserted_ids = 3;
map<string, TimeTicket> created_at_map_by_actor = 4;
TimeTicket executed_at = 5;
map<string, string> attributes = 6;
TimeTicket executed_at = 4;
map<string, string> attributes = 5;
}

oneof body {
Expand Down
4 changes: 0 additions & 4 deletions src/api/yorkie/v1/resources_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,6 @@ export namespace Operation {
clearInsertedIdsList(): EditReverse;
addInsertedIds(value?: TextNodePos, index?: number): TextNodePos;

getCreatedAtMapByActorMap(): jspb.Map<string, TimeTicket>;
clearCreatedAtMapByActorMap(): EditReverse;

getExecutedAt(): TimeTicket | undefined;
setExecutedAt(value?: TimeTicket): EditReverse;
hasExecutedAt(): boolean;
Expand All @@ -673,7 +670,6 @@ export namespace Operation {
parentCreatedAt?: TimeTicket.AsObject,
deletedIdsList: Array<TextNodePos.AsObject>,
insertedIdsList: Array<TextNodePos.AsObject>,
createdAtMapByActorMap: Array<[string, TimeTicket.AsObject]>,
executedAt?: TimeTicket.AsObject,
attributesMap: Array<[string, string]>,
}
Expand Down
51 changes: 9 additions & 42 deletions src/api/yorkie/v1/resources_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5626,7 +5626,6 @@ proto.yorkie.v1.Operation.EditReverse.toObject = function(includeInstance, msg)
proto.yorkie.v1.TextNodePos.toObject, includeInstance),
insertedIdsList: jspb.Message.toObjectList(msg.getInsertedIdsList(),
proto.yorkie.v1.TextNodePos.toObject, includeInstance),
createdAtMapByActorMap: (f = msg.getCreatedAtMapByActorMap()) ? f.toObject(includeInstance, proto.yorkie.v1.TimeTicket.toObject) : [],
executedAt: (f = msg.getExecutedAt()) && proto.yorkie.v1.TimeTicket.toObject(includeInstance, f),
attributesMap: (f = msg.getAttributesMap()) ? f.toObject(includeInstance, undefined) : []
};
Expand Down Expand Up @@ -5681,17 +5680,11 @@ proto.yorkie.v1.Operation.EditReverse.deserializeBinaryFromReader = function(msg
msg.addInsertedIds(value);
break;
case 4:
var value = msg.getCreatedAtMapByActorMap();
reader.readMessage(value, function(message, reader) {
jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.yorkie.v1.TimeTicket.deserializeBinaryFromReader, "", new proto.yorkie.v1.TimeTicket());
});
break;
case 5:
var value = new proto.yorkie.v1.TimeTicket;
reader.readMessage(value,proto.yorkie.v1.TimeTicket.deserializeBinaryFromReader);
msg.setExecutedAt(value);
break;
case 6:
case 5:
var value = msg.getAttributesMap();
reader.readMessage(value, function(message, reader) {
jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", "");
Expand Down Expand Up @@ -5750,21 +5743,17 @@ proto.yorkie.v1.Operation.EditReverse.serializeBinaryToWriter = function(message
proto.yorkie.v1.TextNodePos.serializeBinaryToWriter
);
}
f = message.getCreatedAtMapByActorMap(true);
if (f && f.getLength() > 0) {
f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.yorkie.v1.TimeTicket.serializeBinaryToWriter);
}
f = message.getExecutedAt();
if (f != null) {
writer.writeMessage(
5,
4,
f,
proto.yorkie.v1.TimeTicket.serializeBinaryToWriter
);
}
f = message.getAttributesMap(true);
if (f && f.getLength() > 0) {
f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString);
}
};

Expand Down Expand Up @@ -5883,34 +5872,12 @@ proto.yorkie.v1.Operation.EditReverse.prototype.clearInsertedIdsList = function(


/**
* map<string, TimeTicket> created_at_map_by_actor = 4;
* @param {boolean=} opt_noLazyCreate Do not create the map if
* empty, instead returning `undefined`
* @return {!jspb.Map<string,!proto.yorkie.v1.TimeTicket>}
*/
proto.yorkie.v1.Operation.EditReverse.prototype.getCreatedAtMapByActorMap = function(opt_noLazyCreate) {
return /** @type {!jspb.Map<string,!proto.yorkie.v1.TimeTicket>} */ (
jspb.Message.getMapField(this, 4, opt_noLazyCreate,
proto.yorkie.v1.TimeTicket));
};


/**
* Clears values from the map. The map will be non-null.
* @return {!proto.yorkie.v1.Operation.EditReverse} returns this
*/
proto.yorkie.v1.Operation.EditReverse.prototype.clearCreatedAtMapByActorMap = function() {
this.getCreatedAtMapByActorMap().clear();
return this;};


/**
* optional TimeTicket executed_at = 5;
* optional TimeTicket executed_at = 4;
* @return {?proto.yorkie.v1.TimeTicket}
*/
proto.yorkie.v1.Operation.EditReverse.prototype.getExecutedAt = function() {
return /** @type{?proto.yorkie.v1.TimeTicket} */ (
jspb.Message.getWrapperField(this, proto.yorkie.v1.TimeTicket, 5));
jspb.Message.getWrapperField(this, proto.yorkie.v1.TimeTicket, 4));
};


Expand All @@ -5919,7 +5886,7 @@ proto.yorkie.v1.Operation.EditReverse.prototype.getExecutedAt = function() {
* @return {!proto.yorkie.v1.Operation.EditReverse} returns this
*/
proto.yorkie.v1.Operation.EditReverse.prototype.setExecutedAt = function(value) {
return jspb.Message.setWrapperField(this, 5, value);
return jspb.Message.setWrapperField(this, 4, value);
};


Expand All @@ -5937,19 +5904,19 @@ proto.yorkie.v1.Operation.EditReverse.prototype.clearExecutedAt = function() {
* @return {boolean}
*/
proto.yorkie.v1.Operation.EditReverse.prototype.hasExecutedAt = function() {
return jspb.Message.getField(this, 5) != null;
return jspb.Message.getField(this, 4) != null;
};


/**
* map<string, string> attributes = 6;
* map<string, string> attributes = 5;
* @param {boolean=} opt_noLazyCreate Do not create the map if
* empty, instead returning `undefined`
* @return {!jspb.Map<string,string>}
*/
proto.yorkie.v1.Operation.EditReverse.prototype.getAttributesMap = function(opt_noLazyCreate) {
return /** @type {!jspb.Map<string,string>} */ (
jspb.Message.getMapField(this, 6, opt_noLazyCreate,
jspb.Message.getMapField(this, 5, opt_noLazyCreate,
null));
};

Expand Down
15 changes: 0 additions & 15 deletions src/document/operation/edit_reverse_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,24 @@ export class EditReverseOperation extends Operation {
private deletedIDs: Array<RGATreeSplitPos>;
private insertedIDs: Array<RGATreeSplitPos>;
private attributes?: Map<string, string>;
private maxCreatedAtMapByActor?: Map<string, TimeTicket>;

constructor({
parentCreatedAt,
deletedIDs,
insertedIDs,
attributes,
executedAt,
maxCreatedAtMapByActor,
}: {
parentCreatedAt: TimeTicket;
deletedIDs: Array<RGATreeSplitPos>;
insertedIDs: Array<RGATreeSplitPos>;
attributes?: Map<string, string>;
executedAt?: TimeTicket;
maxCreatedAtMapByActor?: Map<string, TimeTicket>;
}) {
super(parentCreatedAt, executedAt);
this.deletedIDs = deletedIDs;
this.insertedIDs = insertedIDs;
this.attributes = attributes;
this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;
}

/**
Expand All @@ -68,22 +64,19 @@ export class EditReverseOperation extends Operation {
insertedIDs,
attributes,
executedAt,
maxCreatedAtMapByActor,
}: {
parentCreatedAt: TimeTicket;
deletedIDs: Array<RGATreeSplitPos>;
insertedIDs: Array<RGATreeSplitPos>;
attributes?: Map<string, string>;
executedAt?: TimeTicket;
maxCreatedAtMapByActor?: Map<string, TimeTicket>;
}): EditReverseOperation {
return new EditReverseOperation({
parentCreatedAt,
deletedIDs,
insertedIDs,
attributes,
executedAt,
maxCreatedAtMapByActor,
});
}

Expand Down Expand Up @@ -177,12 +170,4 @@ export class EditReverseOperation extends Operation {
public getAttributes(): Map<string, string> {
return this.attributes || new Map();
}

/**
* `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time
* by actor for the nodes included in the editing range.
*/
public getMaxCreatedAtMapByActor(): Map<string, TimeTicket> | undefined {
return this.maxCreatedAtMapByActor;
}
}

0 comments on commit 5716e26

Please sign in to comment.