From ac5b50e4a622ee0885678a96c69af7f49290bcee Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 14 Sep 2018 10:09:38 +0200 Subject: ... --- src/Action/Ports.elm | 2 +- src/ElmModule/Update.elm | 6 ++++++ src/Struct/Event.elm | 4 ++++ src/Struct/Flags.elm | 4 ++-- src/Update/StoreParams.elm | 24 ++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/Update/StoreParams.elm (limited to 'src') diff --git a/src/Action/Ports.elm b/src/Action/Ports.elm index c79d918..4d83077 100644 --- a/src/Action/Ports.elm +++ b/src/Action/Ports.elm @@ -1,4 +1,4 @@ port module Action.Ports exposing (..) -port store_new_params : (Int, (List String)) -> (Cmd msg) +port store_params : (Int, String) -> (Cmd msg) port reset_params : () -> (Cmd msg) diff --git a/src/ElmModule/Update.elm b/src/ElmModule/Update.elm index 5baa84c..fbe8dfe 100644 --- a/src/ElmModule/Update.elm +++ b/src/ElmModule/Update.elm @@ -7,6 +7,7 @@ import Struct.Event import Struct.Model import Update.HandleServerReply +import Update.StoreParams -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -27,6 +28,11 @@ update event model = case event of Struct.Event.None -> (model, Cmd.none) + (Struct.Event.SetUsername str) -> (model, Cmd.none) + (Struct.Event.SetID str) -> (model, Cmd.none) + (Struct.Event.SetURLPrefix str) -> (model, Cmd.none) + (Struct.Event.SetFrequency val) -> (Update.StoreParams.apply_to model) + (Struct.Event.Failed err) -> ( (Struct.Model.invalidate err new_model), diff --git a/src/Struct/Event.elm b/src/Struct/Event.elm index 3bf64d7..68bca98 100644 --- a/src/Struct/Event.elm +++ b/src/Struct/Event.elm @@ -13,6 +13,10 @@ import Struct.ServerReply type Type = None | Failed Struct.Error.Type + | SetUsername String + | SetID String + | SetURLPrefix String + | SetFrequency Int | ServerReplied (Result Http.Error (List Struct.ServerReply.Type)) attempted : (Result.Result err val) -> Type diff --git a/src/Struct/Flags.elm b/src/Struct/Flags.elm index ccda57a..d9d2dcd 100644 --- a/src/Struct/Flags.elm +++ b/src/Struct/Flags.elm @@ -17,7 +17,7 @@ import Util.List type alias Type = { frequency : Int, - players : (List String) + players : String } -------------------------------------------------------------------------------- @@ -30,5 +30,5 @@ type alias Type = get_frequency : Type -> Int get_frequency flags = flags.frequency -get_players : Type -> (List String) +get_players : Type -> String get_players flags = flags.players diff --git a/src/Update/StoreParams.elm b/src/Update/StoreParams.elm new file mode 100644 index 0000000..3955ecd --- /dev/null +++ b/src/Update/StoreParams.elm @@ -0,0 +1,24 @@ +module Update.StoreParams exposing (apply_to) + +-- Elm ------------------------------------------------------------------------- + +-- Login ----------------------------------------------------------------------- +import Action.Ports + +import Struct.Event +import Struct.Flags +import Struct.Model + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type)) +apply_to model = + ( + model, + (Action.Ports.store_params (5, "")) + ) -- cgit v1.2.3-70-g09d2