Avoid alerts blocking route changes

dhcp-server
Pat Hartl 2023-09-01 00:46:37 -05:00
parent 5a93cca6ef
commit 9f4e0b5fe3
2 changed files with 16 additions and 2 deletions

View File

@ -239,7 +239,7 @@ else
{
Game = await GameService.Add(Game);
await MessageService.Success("Game added!");
NavigationManager.LocationChanged += NotifyGameAdded;
NavigationManager.NavigateTo($"/Games/{Game.Id}");
}
@ -250,6 +250,13 @@ else
}
}
private void NotifyGameAdded(object? sender, LocationChangedEventArgs e)
{
NavigationManager.LocationChanged -= NotifyGameAdded;
MessageService.Success("Game added!");
}
private async Task BrowseForIcon()
{
var modalOptions = new ModalOptions()

View File

@ -196,7 +196,7 @@
{
Server = await ServerService.Add(Server);
await MessageService.Success("Server added!");
NavigationManager.LocationChanged += NotifyServerAdded;
NavigationManager.NavigateTo($"/Servers/{Server.Id}");
}
@ -207,6 +207,13 @@
}
}
private void NotifyServerAdded(object? sender, LocationChangedEventArgs e)
{
NavigationManager.LocationChanged -= NotifyServerAdded;
MessageService.Success("Server added!");
}
private string GetIcon(Game game)
{
return $"/api/Games/{game?.Id}/Icon.png";