Skip to content

Commit

Permalink
Cannot set properties of undefined (setting 'serverID')
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed May 13, 2024
1 parent 899735d commit 489cdd6
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion cvat-core/src/annotations-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,16 @@ export class Track extends Drawn {
);
}

protected appendShapeActionToHistory(actionType, frame, undoShape, redoShape, undoSource, redoSource): void {
protected appendShapeActionToHistory(
actionType,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
): void {
this.history.do(
actionType,
() => {
Expand All @@ -1142,6 +1151,7 @@ export class Track extends Drawn {
this.shapes[frame] = undoShape;
}
this.source = undoSource;
this.frame = undoFrame;
this.updated = Date.now();
},
() => {
Expand All @@ -1151,6 +1161,7 @@ export class Track extends Drawn {
this.shapes[frame] = redoShape;
}
this.source = redoSource;
this.frame = redoFrame;
this.updated = Date.now();
},
[this.clientID],
Expand All @@ -1162,102 +1173,127 @@ export class Track extends Drawn {
const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const redoFrame = Math.min(frame, this.frame);
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ?
{ ...this.shapes[frame], rotation } : copyShape(this.get(frame), { rotation });

this.shapes[frame] = redoShape;
this.source = redoSource;
this.frame = redoFrame;
this.appendShapeActionToHistory(
HistoryActions.CHANGED_ROTATION,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

protected savePoints(points: number[], frame: number): void {
const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const redoFrame = Math.min(frame, this.frame);
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ?
{ ...this.shapes[frame], points } : copyShape(this.get(frame), { points });

this.shapes[frame] = redoShape;
this.source = redoSource;
this.frame = redoFrame;
this.appendShapeActionToHistory(
HistoryActions.CHANGED_POINTS,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

protected saveOutside(frame: number, outside: boolean): void {
const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const redoFrame = Math.min(frame, this.frame);
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ?
{ ...this.shapes[frame], outside } :
copyShape(this.get(frame), { outside });

this.shapes[frame] = redoShape;
this.source = redoSource;
this.frame = redoFrame;
this.appendShapeActionToHistory(
HistoryActions.CHANGED_OUTSIDE,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

protected saveOccluded(occluded: boolean, frame: number): void {
const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const redoFrame = Math.min(frame, this.frame);
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ?
{ ...this.shapes[frame], occluded } :
copyShape(this.get(frame), { occluded });

this.shapes[frame] = redoShape;
this.source = redoSource;
this.frame = redoFrame;
this.appendShapeActionToHistory(
HistoryActions.CHANGED_OCCLUDED,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

protected saveZOrder(zOrder: number, frame: number): void {
const wasKeyframe = frame in this.shapes;
const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const redoFrame = Math.min(frame, this.frame);
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = wasKeyframe ?
{ ...this.shapes[frame], zOrder } :
copyShape(this.get(frame), { zOrder });

this.shapes[frame] = redoShape;
this.source = redoSource;
this.frame = redoFrame;
this.appendShapeActionToHistory(
HistoryActions.CHANGED_ZORDER,
frame,
undoShape,
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

Expand All @@ -1270,6 +1306,7 @@ export class Track extends Drawn {

const undoSource = this.source;
const redoSource = this.readOnlyFields.includes('source') ? this.source : computeNewSource(this.source);
const undoFrame = this.frame;
const undoShape = wasKeyframe ? this.shapes[frame] : undefined;
const redoShape = keyframe ? copyShape(this.get(frame)) : undefined;

Expand All @@ -1279,6 +1316,8 @@ export class Track extends Drawn {
} else {
delete this.shapes[frame];
}
const redoFrame = Math.min(...Object.keys(this.shapes).map((key) => +key));
this.frame = redoFrame;

this.appendShapeActionToHistory(
HistoryActions.CHANGED_KEYFRAME,
Expand All @@ -1287,6 +1326,8 @@ export class Track extends Drawn {
redoShape,
undoSource,
redoSource,
undoFrame,
redoFrame,
);
}

Expand Down

0 comments on commit 489cdd6

Please sign in to comment.