updateShape method

void updateShape(
  1. UDocShape shape
)

Replaces a shape. Rapid edits of the same shape (dragging, resizing) share one undo step and one save.

Implementation

void updateShape(UDocShape shape) {
  final int index = _shapes.indexWhere((UDocShape existing) => existing.id == shape.id);
  if (index < 0) return;
  final DateTime now = DateTime.now();
  final bool continuing = _lastShapeEdit == shape.id && now.difference(_lastShapeEditAt) < const Duration(milliseconds: 900);
  if (!continuing) _checkpoint();
  _lastShapeEdit = shape.id;
  _lastShapeEditAt = now;
  _shapes[index] = shape;
  _commit(debounce: true);
}