From 108a09eef2d0875df972fc206232e095005dd0be Mon Sep 17 00:00:00 2001 From: Rukie007 Date: Wed, 25 Oct 2023 02:11:43 +0200 Subject: [PATCH] Fixed appliance error --- .../Components/Advanced/Variants.razor | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/apps/blazor-app/Components/Advanced/Variants.razor b/src/apps/blazor-app/Components/Advanced/Variants.razor index 9553eeaa..d75ebdec 100644 --- a/src/apps/blazor-app/Components/Advanced/Variants.razor +++ b/src/apps/blazor-app/Components/Advanced/Variants.razor @@ -338,7 +338,11 @@ private async void IncrementAppliancePage(){ { IncrementAppliance(defaultAppliance); StateHasChanged(); - } else { + } + + @* + Impossible state I believe, however I am keeping this here just in case + else { appliances.Add(new ApplianceModel { name = "Default", @@ -348,9 +352,15 @@ private async void IncrementAppliancePage(){ powerUsage = power }); StateHasChanged(); - } + } *@ } else { ApplianceModel? newModelGroup = appliances.FirstOrDefault(appliance => appliance.type == type && appliance.name == name && appliance.powerUsage == power); + double duration = 0; + if(defaultAppliance != null) + { + duration = defaultAppliance.durationUsed; + } + if(newModelGroup != null) { IncrementAppliance(newModelGroup); StateHasChanged(); @@ -360,7 +370,7 @@ private async void IncrementAppliancePage(){ name = name, type = type, quantity = 1, - durationUsed = 0, + durationUsed = duration, powerUsage = power }); StateHasChanged();