mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-21 04:12:56 +00:00
Refactor message types for clarity and consistency
This commit is contained in:
parent
647bc0075d
commit
11ddaf7a14
@ -175,19 +175,19 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.SHOW_SUCCESS:
|
case Event.SHOW_SUCCESS:
|
||||||
if (data is Success success)
|
if (data is DataSuccessMessage success)
|
||||||
success.Show(this.Snackbar);
|
success.Show(this.Snackbar);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.SHOW_ERROR:
|
case Event.SHOW_ERROR:
|
||||||
if (data is Error error)
|
if (data is DataErrorMessage error)
|
||||||
error.Show(this.Snackbar);
|
error.Show(this.Snackbar);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.SHOW_WARNING:
|
case Event.SHOW_WARNING:
|
||||||
if (data is Warning warning)
|
if (data is DataWarningMessage warning)
|
||||||
warning.Show(this.Snackbar);
|
warning.Show(this.Snackbar);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
16
app/MindWork AI Studio/Tools/DataErrorMessage.cs
Normal file
16
app/MindWork AI Studio/Tools/DataErrorMessage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public readonly record struct DataErrorMessage(string Icon, string Message)
|
||||||
|
{
|
||||||
|
public void Show(ISnackbar snackbar)
|
||||||
|
{
|
||||||
|
var icon = this.Icon;
|
||||||
|
snackbar.Add(this.Message, Severity.Error, config =>
|
||||||
|
{
|
||||||
|
config.Icon = icon;
|
||||||
|
config.IconSize = Size.Large;
|
||||||
|
config.HideTransitionDuration = 600;
|
||||||
|
config.VisibleStateDuration = 14_000;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
16
app/MindWork AI Studio/Tools/DataSuccessMessage.cs
Normal file
16
app/MindWork AI Studio/Tools/DataSuccessMessage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public readonly record struct DataSuccessMessage(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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
16
app/MindWork AI Studio/Tools/DataWarningMessage.cs
Normal file
16
app/MindWork AI Studio/Tools/DataWarningMessage.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace AIStudio.Tools;
|
||||||
|
|
||||||
|
public readonly record struct DataWarningMessage(string Icon, string Message)
|
||||||
|
{
|
||||||
|
public void Show(ISnackbar snackbar)
|
||||||
|
{
|
||||||
|
var icon = this.Icon;
|
||||||
|
snackbar.Add(this.Message, Severity.Warning, config =>
|
||||||
|
{
|
||||||
|
config.Icon = icon;
|
||||||
|
config.IconSize = Size.Large;
|
||||||
|
config.HideTransitionDuration = 600;
|
||||||
|
config.VisibleStateDuration = 12_000;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,46 +0,0 @@
|
|||||||
namespace AIStudio.Tools;
|
|
||||||
|
|
||||||
public readonly record struct Error(string Icon, string Message)
|
|
||||||
{
|
|
||||||
public void Show(ISnackbar snackbar)
|
|
||||||
{
|
|
||||||
var icon = this.Icon;
|
|
||||||
snackbar.Add(this.Message, Severity.Error, config =>
|
|
||||||
{
|
|
||||||
config.Icon = icon;
|
|
||||||
config.IconSize = Size.Large;
|
|
||||||
config.HideTransitionDuration = 600;
|
|
||||||
config.VisibleStateDuration = 14_000;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly record struct Warning(string Icon, string Message)
|
|
||||||
{
|
|
||||||
public void Show(ISnackbar snackbar)
|
|
||||||
{
|
|
||||||
var icon = this.Icon;
|
|
||||||
snackbar.Add(this.Message, Severity.Warning, config =>
|
|
||||||
{
|
|
||||||
config.Icon = icon;
|
|
||||||
config.IconSize = Size.Large;
|
|
||||||
config.HideTransitionDuration = 600;
|
|
||||||
config.VisibleStateDuration = 12_000;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -66,11 +66,11 @@ public sealed class MessageBus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SendError(Error error) => this.SendMessage(null, Event.SHOW_ERROR, error);
|
public Task SendError(DataErrorMessage dataErrorMessage) => this.SendMessage(null, Event.SHOW_ERROR, dataErrorMessage);
|
||||||
|
|
||||||
public Task SendWarning(Warning warning) => this.SendMessage(null, Event.SHOW_WARNING, warning);
|
public Task SendWarning(DataWarningMessage dataWarningMessage) => this.SendMessage(null, Event.SHOW_WARNING, dataWarningMessage);
|
||||||
|
|
||||||
public Task SendSuccess(Success success) => this.SendMessage(null, Event.SHOW_SUCCESS, success);
|
public Task SendSuccess(DataSuccessMessage dataSuccessMessage) => this.SendMessage(null, Event.SHOW_SUCCESS, dataSuccessMessage);
|
||||||
|
|
||||||
public void DeferMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data = default)
|
public void DeferMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data = default)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user