From d6fb1403dee6f5fbeb181c3f1b2f348765083ab5 Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Tue, 31 Aug 2021 19:36:23 +0200 Subject: [PATCH] fixed bug where waiting on the confirm screen could place the first step into the past --- lib/pages/AddPizzaEventPage.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pages/AddPizzaEventPage.dart b/lib/pages/AddPizzaEventPage.dart index 4385276..cb75218 100644 --- a/lib/pages/AddPizzaEventPage.dart +++ b/lib/pages/AddPizzaEventPage.dart @@ -169,6 +169,15 @@ class AddPizzaEventPageState extends State { if (eventTime == null){ return; } + + // if the user waited to long on the confirmation dialog that the first step time is now in the past + var durationUntilFirstStep = Duration(seconds: this.widget.pizzaRecipe.getCurrentDuration().inSeconds); + var firstStepDateTime = eventTime.subtract(durationUntilFirstStep); + if (firstStepDateTime.isBefore(DateTime.now())){ + eventTime = DateTime.now() + .add(durationUntilFirstStep) + .add(const Duration(minutes: 1)); + } var pizzaEventsBox = Hive.box("PizzaEvents"); PizzaEvent pizzaEvent = PizzaEvent(