Avoid null references on game edit/add page

blazor
Pat Hartl 2023-03-03 17:40:59 -06:00
parent 5b7bd5140c
commit 285cb07e37
5 changed files with 18 additions and 0 deletions

View File

@ -60,6 +60,9 @@
protected override async Task OnInitializedAsync()
{
if (Game.Actions == null)
Game.Actions = new List<Data.Models.Action>();
OrderedActions = Game.Actions.OrderBy(a => a.SortOrder).ToList();
FixSortOrder();
}

View File

@ -99,6 +99,9 @@
protected override async Task OnInitializedAsync()
{
if (Game.Archives == null)
Game.Archives = new List<Archive>();
HttpClient.BaseAddress = new Uri(Navigator.BaseUri);
Archive = new Archive()

View File

@ -78,6 +78,9 @@
protected override async Task OnInitializedAsync()
{
if (Game.Keys == null)
Game.Keys = new List<Key>();
AllocatedKeys = Game.Keys.Count(k => k.IsAllocated());
}

View File

@ -38,6 +38,12 @@
@code {
[Parameter] public Game Game { get; set; }
protected override async Task OnInitializedAsync()
{
if (Game.MultiplayerModes == null)
Game.MultiplayerModes = new List<MultiplayerMode>();
}
private void AddMode()
{
if (Game.MultiplayerModes == null)

View File

@ -110,6 +110,9 @@
protected override async Task OnInitializedAsync()
{
if (Game.Scripts == null)
Game.Scripts = new List<Script>();
Snippets = ScriptService.GetSnippets();
if (Script == null)