Skip to content

Commit

Permalink
feat(rhino): wraps receive in an undo operation (#544)
Browse files Browse the repository at this point in the history
* feat(rhino): wraps receive in an undo operation

* fix: formatting
  • Loading branch information
didimitrie authored Feb 1, 2025
1 parent 3a7baf0 commit e9f3701
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public async Task Receive(string modelCardId)
scope
.ServiceProvider.GetRequiredService<IConverterSettingsStore<RhinoConversionSettings>>()
.Initialize(_rhinoConversionSettingsFactory.Create(RhinoDoc.ActiveDoc));

uint undoRecord = 0;
try
{
// Get receiver card
Expand All @@ -70,6 +72,7 @@ public async Task Receive(string modelCardId)

CancellationToken cancellationToken = _cancellationManager.InitCancellationTokenSource(modelCardId);

undoRecord = RhinoDoc.ActiveDoc.BeginUndoRecord($"Receive Speckle model {modelCard.ModelName}");
// Receive host objects
HostObjectBuilderResult conversionResults = await scope
.ServiceProvider.GetRequiredService<ReceiveOperation>()
Expand Down Expand Up @@ -98,6 +101,10 @@ await Commands.SetModelReceiveResult(
_logger.LogModelCardHandledError(ex);
await Commands.SetModelError(modelCardId, ex);
}
finally
{
RhinoDoc.ActiveDoc.EndUndoRecord(undoRecord);
}
}

public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
Expand Down

0 comments on commit e9f3701

Please sign in to comment.