Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DUI3-448 both model card types need 2 clicks to actually cancel 1 to stop operation and 1 to refresh progress bar #3538

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public async Task Receive(string modelCardId)
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
cts.Token,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress)
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
)
.ConfigureAwait(false);

Expand All @@ -77,10 +78,5 @@ public async Task Receive(string modelCardId)
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}

public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ public async Task Send(string modelCardId)
.Execute(
mapMembers,
sendInfo,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
)
.ConfigureAwait(false);
Expand Down Expand Up @@ -407,9 +408,4 @@ private void RunExpirationChecks(bool idsDeleted)
Commands.SetModelsExpired(expiredSenderIds);
ChangedObjectIds = new HashSet<string>();
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public async Task Receive(string modelCardId)
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
cts.Token,
onOperationProgressed: (status, progress) => OnSendOperationProgress(modelCardId, status, progress)
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
)
.ConfigureAwait(false);

Expand All @@ -83,9 +84,4 @@ public async Task Receive(string modelCardId)
Application.DocumentManager.DocumentActivationEnabled = true;
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ private async Task SendInternal(string modelCardId)
.Execute(
autocadObjects,
sendInfo,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
)
.ConfigureAwait(false);
Expand All @@ -191,10 +192,5 @@ private async Task SendInternal(string modelCardId)
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}

public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public async Task Send(string modelCardId)
.Execute(
revitObjects,
sendInfo,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
)
.ConfigureAwait(false);
Expand All @@ -130,11 +131,6 @@ public async Task Send(string modelCardId)
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}

/// <summary>
/// Keeps track of the changed element ids as well as checks if any of them need to trigger
/// a filter refresh (e.g., views being added).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public async Task Receive(string modelCardId)
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
cts.Token,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress)
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
)
.ConfigureAwait(false);

Expand All @@ -79,10 +80,5 @@ public async Task Receive(string modelCardId)
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}

public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ public async Task Send(string modelCardId)
.Execute(
rhinoObjects,
sendInfo,
(status, progress) => OnSendOperationProgress(modelCardId, status, progress),
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts),
cts.Token
)
.ConfigureAwait(false);
Expand All @@ -193,11 +194,6 @@ public async Task Send(string modelCardId)
}
}

private void OnSendOperationProgress(string modelCardId, string status, double? progress)
{
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress));
}

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

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ public void SetGlobalNotification(ToastNotificationType type, string title, stri
}
);

public void SetModelProgress(string modelCardId, ModelCardProgress progress) =>
Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress });
public void SetModelProgress(string modelCardId, ModelCardProgress progress, CancellationTokenSource cts)
{
// NOTE: To prevent potential race condition
// After cancelling operation some parts could still send last progress update which was set progress on UI
// after it forced to be undefined. This is the safest way to prevent any case like this.
if (!cts.IsCancellationRequested)
{
Bridge.Send(SET_MODEL_PROGRESS_UI_COMMAND_NAME, new { modelCardId, progress });
}
}

public void SetModelError(string modelCardId, Exception error) =>
Bridge.Send(SET_MODEL_ERROR_UI_COMMAND_NAME, new { modelCardId, error = error.Message });
Expand Down
Loading