Class UndoToastService

Assembly: redb.Identity.Web.dll

Optimistic-mutation orchestrator. Replaces "Are you sure?" confirm dialogs
for soft / reversible operations (disable, archive, hide).
Typical use:
// 1. Optimistic UI update
app.Enabled = false;
StateHasChanged();

// 2. Show toast and wait for user verdict
var commit = await UndoToast.PromptAsync(
$"Application '{app.Name}' disabled",
durationMs: 8000);

if (commit)
{
// Toast expired — user is fine with it. Persist.
await Client.DisableApplicationAsync(app.Id);
}
else
{
// User clicked Undo before the timer expired. Roll back the UI.
app.Enabled = true;
StateHasChanged();
}

Why this pattern instead of confirm-modal:

No modal-overlay disruption — user keeps working.
Optimistic feedback is immediate, server commit is delayed.
The Undo affordance is one-click, not a multi-step modal Q&A.

One toast at a time: if a second prompt arrives while one is on screen,
the first is auto-committed and removed before the second appears. This
matches macOS / GMail snackbar semantics.

public sealed class UndoToastService

Inheritance

Object→UndoToastService

Methods

PromptAsync(string, int)

Display an undoable action toast and wait for the user's verdict.

public Task<bool> PromptAsync(string message, int durationMs = 8000)

Undo()

Called by the UI when the user clicks Undo. Resolves the active

public void Undo()