From b4e11a7264e69ccec4d12bb88e22369659d891c9 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sat, 1 Aug 2020 11:07:18 +0200 Subject: [PATCH] Fixes a race condition when initializing the calendar-event field The problem was that the field executes a request to validate its state. This was initiated at the same time for two values. Then it was undetermined which value comes back first. --- modules/webapp/src/main/elm/Comp/CalEventInput.elm | 6 ++++++ modules/webapp/src/main/elm/Comp/NotificationForm.elm | 5 ++--- modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm | 5 ++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/CalEventInput.elm b/modules/webapp/src/main/elm/Comp/CalEventInput.elm index eb8aa3ef..49e27b9f 100644 --- a/modules/webapp/src/main/elm/Comp/CalEventInput.elm +++ b/modules/webapp/src/main/elm/Comp/CalEventInput.elm @@ -2,6 +2,7 @@ module Comp.CalEventInput exposing ( Model , Msg , init + , initDefault , update , view ) @@ -36,6 +37,11 @@ type Msg | CheckInputMsg CalEvent (Result Http.Error CalEventCheckResult) +initDefault : Model +initDefault = + Model Nothing + + init : Flags -> CalEvent -> ( Model, Cmd Msg ) init flags ev = ( Model Nothing, checkInput flags ev ) diff --git a/modules/webapp/src/main/elm/Comp/NotificationForm.elm b/modules/webapp/src/main/elm/Comp/NotificationForm.elm index 08eccb4a..82ddaefb 100644 --- a/modules/webapp/src/main/elm/Comp/NotificationForm.elm +++ b/modules/webapp/src/main/elm/Comp/NotificationForm.elm @@ -133,8 +133,8 @@ init flags = initialSchedule = Data.Validated.Unknown Data.CalEvent.everyMonth - ( sm, sc ) = - Comp.CalEventInput.init flags Data.CalEvent.everyMonth + sm = + Comp.CalEventInput.initDefault in ( { settings = Api.Model.NotificationSettings.empty , connectionModel = @@ -159,7 +159,6 @@ init flags = , Cmd.batch [ Api.getMailSettings flags "" ConnResp , Api.getTags flags "" GetTagsResp - , Cmd.map CalEventMsg sc ] ) diff --git a/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm b/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm index 46d842e5..0ceeee73 100644 --- a/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm +++ b/modules/webapp/src/main/elm/Comp/ScanMailboxForm.elm @@ -136,8 +136,8 @@ init flags = initialSchedule = Data.Validated.Unknown Data.CalEvent.everyMonth - ( sm, sc ) = - Comp.CalEventInput.init flags Data.CalEvent.everyMonth + sm = + Comp.CalEventInput.initDefault in ( { settings = Api.Model.ScanMailboxSettings.empty , connectionModel = @@ -168,7 +168,6 @@ init flags = } , Cmd.batch [ Api.getImapSettings flags "" ConnResp - , Cmd.map CalEventMsg sc , Api.getFolders flags "" False GetFolderResp ] )