Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/plugins/liveobjects/livecounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export class LiveCounter extends LiveObject<LiveCounterData, LiveCounterUpdate>
update = this.tombstone(objectMessage);
} else {
// otherwise override data for this object with data from the object state
this._createOperationIsMerged = false; // RTLC6b
this._dataRef = { data: objectState.counter?.count ?? 0 }; // RTLC6c
// RTLC6d
if (!this._client.Utils.isNil(objectState.createOp)) {
Expand Down Expand Up @@ -254,7 +253,6 @@ export class LiveCounter extends LiveObject<LiveCounterData, LiveCounterUpdate>
// if we got here, it means that current counter instance is missing the initial value in its data reference,
// which we're going to add now.
this._dataRef.data += objectOperation.counter?.count ?? 0; // RTLC6d1
this._createOperationIsMerged = true; // RTLC6d2

return {
update: { amount: objectOperation.counter?.count ?? 0 },
Expand All @@ -275,19 +273,6 @@ export class LiveCounter extends LiveObject<LiveCounterData, LiveCounterUpdate>
op: ObjectOperation<ObjectData>,
msg: ObjectMessage,
): LiveCounterUpdate | LiveObjectUpdateNoop {
if (this._createOperationIsMerged) {
// There can't be two different create operation for the same object id, because the object id
// fully encodes that operation. This means we can safely ignore any new incoming create operations
// if we already merged it once.
this._client.Logger.logAction(
this._client.logger,
this._client.Logger.LOG_MICRO,
'LiveCounter._applyCounterCreate()',
`skipping applying COUNTER_CREATE op on a counter instance as it was already applied before; objectId=${this.getObjectId()}`,
);
return { noop: true };
}

return this._mergeInitialDataFromCreateOperation(op, msg);
}

Expand Down
16 changes: 0 additions & 16 deletions src/plugins/liveobjects/livemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
update = this.tombstone(objectMessage);
} else {
// otherwise override data for this object with data from the object state
this._createOperationIsMerged = false; // RTLM6b
this._dataRef = this._liveMapDataFromMapEntries(objectState.map?.entries ?? {}); // RTLM6c
// RTLM6d
if (!this._client.Utils.isNil(objectState.createOp)) {
Expand Down Expand Up @@ -678,8 +677,6 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
Object.assign(aggregatedUpdate.update, update.update);
});

this._createOperationIsMerged = true; // RTLM6d2

return aggregatedUpdate;
}

Expand All @@ -695,19 +692,6 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
op: ObjectOperation<ObjectData>,
msg: ObjectMessage,
): LiveMapUpdate<T> | LiveObjectUpdateNoop {
if (this._createOperationIsMerged) {
// There can't be two different create operation for the same object id, because the object id
// fully encodes that operation. This means we can safely ignore any new incoming create operations
// if we already merged it once.
this._client.Logger.logAction(
this._client.logger,
this._client.Logger.LOG_MICRO,
'LiveMap._applyMapCreate()',
`skipping applying MAP_CREATE op on a map instance as it was already applied before; objectId=${this.getObjectId()}`,
);
return { noop: true };
}

if (this._semantics !== op.map?.semantics) {
throw new this._client.ErrorInfo(
`Cannot apply MAP_CREATE op on LiveMap objectId=${this.getObjectId()}; map's semantics=${this._semantics}, but op expected ${op.map?.semantics}`,
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/liveobjects/liveobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export abstract class LiveObject<
*/
protected _dataRef: TData;
protected _siteTimeserials: Record<string, string>;
protected _createOperationIsMerged: boolean;
private _tombstone: boolean;
private _tombstonedAt: number | undefined;
/**
Expand All @@ -63,7 +62,6 @@ export abstract class LiveObject<
this._dataRef = this._getZeroValueData();
// use empty map of serials by default, so any future operation can be applied to this object
this._siteTimeserials = {};
this._createOperationIsMerged = false;
this._tombstone = false;
this._parentReferences = new Map<LiveObject, Set<string>>();
}
Expand Down
Loading