From 5c235369a79e5b9756d952c73f79b18718a87301 Mon Sep 17 00:00:00 2001 From: Li Date: Mon, 25 Dec 2023 07:06:16 +1000 Subject: [PATCH] Fix the clear repcount It had an issue where the callback for clearing would run on a different synch context so updating the state did not cause it to update. Fluxor usually deals with this, but we use it in the tips section now without fluxor --- LiftLog.App/LiftLog.App.csproj | 8 +++++--- LiftLog.App/install.sh | 2 +- .../Shared/Presentation/PotentialSetCounter.razor | 11 +++++------ .../Shared/Smart/Tips/HoldingRepCounterTip.razor | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/LiftLog.App/LiftLog.App.csproj b/LiftLog.App/LiftLog.App.csproj index eef62e70..ba02f953 100644 --- a/LiftLog.App/LiftLog.App.csproj +++ b/LiftLog.App/LiftLog.App.csproj @@ -2,7 +2,9 @@ net8.0-android; - net8.0-android + net8.0-ios + net8.0-android + net8.0 $(TargetFrameworks);net8.0-ios; Exe @@ -22,8 +24,8 @@ 71733E37-6FDD-4EEF-A0BF-DE32634D58EC - 1.13.0 - 43 + 1.13.1 + 44 14.2 24.0 diff --git a/LiftLog.App/install.sh b/LiftLog.App/install.sh index 3c28e6fd..47e7af26 100755 --- a/LiftLog.App/install.sh +++ b/LiftLog.App/install.sh @@ -16,4 +16,4 @@ if [ "$1" == "-c" ]; then dotnet clean -f net8.0-android fi -dotnet build -t:Run -c Debug -f net8.0-android -p:TargetFramework=net8.0-android -p:ExtraDefineConstants=TEST_MODE #-p:AndroidEnableProfiler=true +dotnet build -t:Run -c Debug -f net8.0-android -p:TargetFramework=net8.0-android -p:BuildFor=android -p:ExtraDefineConstants=TEST_MODE #-p:AndroidEnableProfiler=true diff --git a/LiftLog.Ui/Shared/Presentation/PotentialSetCounter.razor b/LiftLog.Ui/Shared/Presentation/PotentialSetCounter.razor index ead048eb..45e7be1b 100644 --- a/LiftLog.Ui/Shared/Presentation/PotentialSetCounter.razor +++ b/LiftLog.Ui/Shared/Presentation/PotentialSetCounter.razor @@ -115,13 +115,12 @@ private string? RepCountToStartClass => ToStartNext ? "" : null; - private void OnPointerDown(PointerEventArgs args){ + private async void OnPointerDown(PointerEventArgs args){ _lastPointerDownTime = DateTime.Now; - Task.Delay(500).ContinueWith(_ => { - if (_lastPointerDownTime is null || _lastPointerDownTime.Value.AddMilliseconds(500) > DateTime.Now) return; - _clearRepCountTime = DateTime.Now; - ClearRepCount(); - }); + await Task.Delay(500); + if (_lastPointerDownTime is null || _lastPointerDownTime.Value.AddMilliseconds(500) > DateTime.Now) return; + _clearRepCountTime = DateTime.Now; + ClearRepCount(); } protected override async Task OnAfterRenderAsync(bool firstRender) diff --git a/LiftLog.Ui/Shared/Smart/Tips/HoldingRepCounterTip.razor b/LiftLog.Ui/Shared/Smart/Tips/HoldingRepCounterTip.razor index bb5c3e3e..53371561 100644 --- a/LiftLog.Ui/Shared/Smart/Tips/HoldingRepCounterTip.razor +++ b/LiftLog.Ui/Shared/Smart/Tips/HoldingRepCounterTip.razor @@ -9,7 +9,7 @@ CycleRepCount=@(() => CycleRepCountForSet()) ClearRepCount=@(() => ClearRepCountForSet()) UpdateWeight=@((_)=>{}) - ToStartNext=false /> + ToStartNext=@(set.Set is null) /> @code{ private PotentialSet set = new PotentialSet(new RecordedSet(8, TimeOnly.MinValue), 10m); @@ -33,7 +33,7 @@ private void ClearRepCountForSet() { set = set with { Set = null }; - StateHasChanged(); + InvokeAsync(StateHasChanged); }