remember selected collection (#36)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
@using ErsatzTV.Application.MediaCollections
|
||||
@using Microsoft.Extensions.Caching.Memory
|
||||
@using ErsatzTV.Application.MediaCollections
|
||||
@using ErsatzTV.Application.MediaCollections.Queries
|
||||
@inject IMediator Mediator
|
||||
@inject IMemoryCache MemoryCache
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@@ -46,12 +48,22 @@
|
||||
|
||||
private MediaCollectionViewModel _selectedCollection;
|
||||
|
||||
protected override async Task OnParametersSetAsync() =>
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_collections = await Mediator.Send(new GetAllCollections());
|
||||
if (MemoryCache.TryGetValue("AddToCollectionDialog.SelectedCollectionId", out int id))
|
||||
{
|
||||
_selectedCollection = _collections.SingleOrDefault(c => c.Id == id);
|
||||
}
|
||||
}
|
||||
|
||||
private string FormatText() => $"Select the collection to add the {EntityType} {EntityName}";
|
||||
|
||||
private void Submit() => MudDialog.Close(DialogResult.Ok(_selectedCollection));
|
||||
private void Submit()
|
||||
{
|
||||
MemoryCache.Set("AddToCollectionDialog.SelectedCollectionId", _selectedCollection.Id);
|
||||
MudDialog.Close(DialogResult.Ok(_selectedCollection));
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user