mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 07:59:47 +00:00
Added a success event to the message bus for better ux
This commit is contained in:
parent
62a4549f89
commit
ca98c5548e
@ -14,3 +14,18 @@ public readonly record struct Error(string Icon, string Message)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct Success(string Icon, string Message)
|
||||
{
|
||||
public void Show(ISnackbar snackbar)
|
||||
{
|
||||
var icon = this.Icon;
|
||||
snackbar.Add(this.Message, Severity.Success, config =>
|
||||
{
|
||||
config.Icon = icon;
|
||||
config.IconSize = Size.Large;
|
||||
config.HideTransitionDuration = 600;
|
||||
config.VisibleStateDuration = 10_000;
|
||||
});
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ public enum Event
|
||||
COLOR_THEME_CHANGED,
|
||||
PLUGINS_RELOADED,
|
||||
SHOW_ERROR,
|
||||
SHOW_SUCCESS,
|
||||
|
||||
// Update events:
|
||||
USER_SEARCH_FOR_UPDATE,
|
||||
|
@ -68,6 +68,8 @@ public sealed class MessageBus
|
||||
|
||||
public Task SendError(Error error) => this.SendMessage(null, Event.SHOW_ERROR, error);
|
||||
|
||||
public Task SendSuccess(Success success) => this.SendMessage(null, Event.SHOW_SUCCESS, success);
|
||||
|
||||
public void DeferMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data = default)
|
||||
{
|
||||
if (this.deferredMessages.TryGetValue(triggeredEvent, out var queue))
|
||||
|
Loading…
Reference in New Issue
Block a user