You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
@implements IDisposable; |
|
|
|
@inject ISearchService SearchService |
|
@inject IJSRuntime JsRuntime |
|
|
|
<SearchDialogComponent></SearchDialogComponent> |
|
|
|
@code { |
|
protected override void OnInitialized() |
|
{ |
|
base.OnInitialized(); |
|
SearchService.Subscribe(OnUpdate); |
|
} |
|
|
|
protected override async Task OnInitializedAsync() |
|
{ |
|
await SearchService.Load(); |
|
await JsRuntime.InvokeVoidAsync("SetDotnetReference", DotNetObjectReference.Create(this)); |
|
} |
|
|
|
|
|
|
|
void IDisposable.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("k") && (ctrlKey || shiftKey || altKey || metaKey)) |
|
{ |
|
if (SearchService.IsVisible) |
|
{ |
|
SearchService.Hide(); |
|
} |
|
else |
|
{ |
|
SearchService.Show(); |
|
} |
|
} |
|
} |
|
|
|
} |