Fixed the "send to" issue, where you could select the bias-of-the-day (#183)

This commit is contained in:
Thorsten Sommer 2024-11-02 11:55:09 +01:00 committed by GitHub
parent 8bd54e6d61
commit bd97c0fb4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 9 deletions

View File

@ -51,11 +51,8 @@
@if (this.ShowSendTo) @if (this.ShowSendTo)
{ {
<MudMenu StartIcon="@Icons.Material.Filled.Apps" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Send to ..." Variant="Variant.Filled" Style="@this.GetSendToColor()" Class="rounded"> <MudMenu StartIcon="@Icons.Material.Filled.Apps" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Send to ..." Variant="Variant.Filled" Style="@this.GetSendToColor()" Class="rounded">
@foreach (var assistant in Enum.GetValues<Components>().OrderBy(n => n.Name().Length)) @foreach (var assistant in Enum.GetValues<Components>().Where(n => n.AllowSendTo()).OrderBy(n => n.Name().Length))
{ {
if (assistant is Components.NONE || this.Component == assistant)
continue;
<MudMenuItem OnClick="() => this.SendToAssistant(assistant, new())"> <MudMenuItem OnClick="() => this.SendToAssistant(assistant, new())">
@assistant.Name() @assistant.Name()
</MudMenuItem> </MudMenuItem>
@ -84,11 +81,8 @@
case SendToButton sendToButton: case SendToButton sendToButton:
<MudMenu StartIcon="@Icons.Material.Filled.Apps" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Send to ..." Variant="Variant.Filled" Style="@this.GetSendToColor()" Class="rounded"> <MudMenu StartIcon="@Icons.Material.Filled.Apps" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Send to ..." Variant="Variant.Filled" Style="@this.GetSendToColor()" Class="rounded">
@foreach (var assistant in Enum.GetValues<Components>().OrderBy(n => n.Name().Length)) @foreach (var assistant in Enum.GetValues<Components>().Where(n => n.AllowSendTo()).OrderBy(n => n.Name().Length))
{ {
if(assistant is Components.NONE || sendToButton.Self == assistant)
continue;
<MudMenuItem OnClick="() => this.SendToAssistant(assistant, sendToButton)"> <MudMenuItem OnClick="() => this.SendToAssistant(assistant, sendToButton)">
@assistant.Name() @assistant.Name()
</MudMenuItem> </MudMenuItem>

View File

@ -267,6 +267,9 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton) protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton)
{ {
if (!destination.AllowSendTo())
return Task.CompletedTask;
var contentToSend = sendToButton == default ? string.Empty : sendToButton.UseResultingContentBlockData switch var contentToSend = sendToButton == default ? string.Empty : sendToButton.UseResultingContentBlockData switch
{ {
false => sendToButton.GetText(), false => sendToButton.GetText(),

View File

@ -5,6 +5,14 @@ namespace AIStudio.Tools;
public static class ComponentsExtensions public static class ComponentsExtensions
{ {
public static bool AllowSendTo(this Components component) => component switch
{
Components.NONE => false,
Components.BIAS_DAY_ASSISTANT => false,
_ => true,
};
public static string Name(this Components component) => component switch public static string Name(this Components component) => component switch
{ {
Components.GRAMMAR_SPELLING_ASSISTANT => "Grammar & Spelling Assistant", Components.GRAMMAR_SPELLING_ASSISTANT => "Grammar & Spelling Assistant",

View File

@ -1,3 +1,4 @@
# v0.9.16, build 191 (2024-11-xx xx:xx UTC) # v0.9.16, build 191 (2024-11-xx xx:xx UTC)
- Added our second financial contributor: Thanks `peerschuett` for supporting AI Studio financially. - Added our second financial contributor: Thanks `peerschuett` for supporting AI Studio financially.
- Improved the layout of the app window, for example, in full-screen mode on large or high-resolution monitors. - Improved the layout of the app window, for example, in full-screen mode on large or high-resolution monitors.
- Fixed the "send to" issue, where you could select the bias-of-the-day assistant as destination.