mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-12-05 03:04:35 +00:00
Kept the inputs of assistants when you leave them (#1209)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
1fbc1f4796
commit
7e2f83b19b
83 files changed
+1924
-347
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
@@ -64,14 +65,7 @@ public partial class DebouncedTextField : MudComponentBase, IDisposable
|
||||
this.debounceTimer.Elapsed += (_, _) =>
|
||||
{
|
||||
this.debounceTimer.Stop();
|
||||
this.InvokeAsync(async () =>
|
||||
{
|
||||
// The parent hands this text back with its next render, which is no change of its own, cf. OnParametersSetAsync:
|
||||
this.lastParameterText = this.text;
|
||||
await this.TextChanged.InvokeAsync(this.text);
|
||||
}).Observe($"{nameof(DebouncedTextField)}: notifying about changed text");
|
||||
this.InvokeAsync(async () => await this.WhenTextChangedAsync(this.text)).Observe($"{nameof(DebouncedTextField)}: handling changed text asynchronously");
|
||||
this.InvokeAsync(() => this.WhenTextCanged(this.text)).Observe($"{nameof(DebouncedTextField)}: handling changed text");
|
||||
this.HandOnText();
|
||||
};
|
||||
|
||||
this.isInitialized = true;
|
||||
@@ -117,6 +111,38 @@ public partial class DebouncedTextField : MudComponentBase, IDisposable
|
||||
this.debounceTimer.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hands a text which still waits for the debounce time on at once, as soon as the user leaves the field.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A click elsewhere, e.g., into the navigation, takes the focus first. So the parent gets the last characters
|
||||
/// typed before it goes away, e.g., an assistant which keeps its inputs as a draft when the user leaves it.
|
||||
/// Otherwise, they would be lost together with this field.
|
||||
/// </remarks>
|
||||
private void OnBlur(FocusEventArgs _)
|
||||
{
|
||||
if (!this.debounceTimer.Enabled)
|
||||
return;
|
||||
|
||||
this.debounceTimer.Stop();
|
||||
this.HandOnText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hands the text on to the parent and to the handlers of a changed text.
|
||||
/// </summary>
|
||||
private void HandOnText()
|
||||
{
|
||||
this.InvokeAsync(async () =>
|
||||
{
|
||||
// The parent hands this text back with its next render, which is no change of its own, cf. OnParametersSetAsync:
|
||||
this.lastParameterText = this.text;
|
||||
await this.TextChanged.InvokeAsync(this.text);
|
||||
}).Observe($"{nameof(DebouncedTextField)}: notifying about changed text");
|
||||
this.InvokeAsync(async () => await this.WhenTextChangedAsync(this.text)).Observe($"{nameof(DebouncedTextField)}: handling changed text asynchronously");
|
||||
this.InvokeAsync(() => this.WhenTextCanged(this.text)).Observe($"{nameof(DebouncedTextField)}: handling changed text");
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in new issue
Block a user