detect cycles in smart collection queries (#2059)

This commit is contained in:
Jason Dove
2025-06-23 01:45:17 +00:00
committed by GitHub
parent 1fb27e3cfa
commit b90463e3af
32 changed files with 300 additions and 71 deletions
@@ -43,6 +43,9 @@
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; }
[Parameter]
public string Query { get; set; }
private readonly SmartCollectionViewModel _newCollection = new(-1, "(New Collection)", string.Empty);
private string _newCollectionName;
@@ -88,13 +91,13 @@
if (_selectedCollection == _newCollection)
{
Either<BaseError, SmartCollectionViewModel> maybeResult =
await Mediator.Send(new CreateSmartCollection(string.Empty, _newCollectionName), _cts.Token);
await Mediator.Send(new CreateSmartCollection(Query, _newCollectionName), _cts.Token);
maybeResult.Match(
collection =>
{
MemoryCache.Set("SaveAsSmartCollectionDialog.SelectedCollectionId", collection.Id);
MudDialog.Close(DialogResult.Ok(collection));
MudDialog.Close(DialogResult.Ok(new Tuple<SmartCollectionViewModel, bool>(collection, false)));
},
error =>
{
@@ -106,7 +109,7 @@
else
{
MemoryCache.Set("SaveAsSmartCollectionDialog.SelectedCollectionId", _selectedCollection.Id);
MudDialog.Close(DialogResult.Ok(_selectedCollection));
MudDialog.Close(DialogResult.Ok(new Tuple<SmartCollectionViewModel, bool>(_selectedCollection, true)));
}
}