Agent code and restructuring
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject ISearchService searchService
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
<SearchDialogComponent></SearchDialogComponent>
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
searchService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await searchService.Load();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await jsRuntime.InvokeVoidAsync("SetDotnetReference", DotNetObjectReference.Create(this));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
searchService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
[JSInvokable("OnKeyPress")]
|
||||
public async Task OnKeyPress(string code, bool ctrlKey, bool shiftKey, bool altKey, bool metaKey)
|
||||
{
|
||||
if (code.ToLower().Equals("/"))
|
||||
{
|
||||
if (searchService.IsVisible)
|
||||
{
|
||||
searchService.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
searchService.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user