diff --git a/Content/default/src/Client/Index.fs b/Content/default/src/Client/Index.fs index d521350f..bc381cf0 100644 --- a/Content/default/src/Client/Index.fs +++ b/Content/default/src/Client/Index.fs @@ -12,7 +12,7 @@ type Model = { type Msg = | SetInput of string | LoadTodos of ApiCall - | SaveTodo of ApiCall + | SaveTodo of ApiCall let todosApi = Api.makeProxy () @@ -40,10 +40,10 @@ let update msg model = Cmd.OfAsync.perform todosApi.addTodo todo (Finished >> SaveTodo) { model with Input = "" }, saveTodoCmd - | Finished todo -> + | Finished todos -> { model with - Todos = model.Todos |> RemoteData.map (fun todos -> todos @ [ todo ]) + Todos = RemoteData.Loaded todos }, Cmd.none diff --git a/Content/default/src/Server/Server.fs b/Content/default/src/Server/Server.fs index f970e2dc..d059237c 100644 --- a/Content/default/src/Server/Server.fs +++ b/Content/default/src/Server/Server.fs @@ -25,7 +25,7 @@ let todosApi ctx = { fun todo -> async { return match Storage.addTodo todo with - | Ok() -> todo + | Ok() -> Storage.todos |> List.ofSeq | Error e -> failwith e } } diff --git a/Content/default/src/Shared/Shared.fs b/Content/default/src/Shared/Shared.fs index 252e6244..5cf35420 100644 --- a/Content/default/src/Shared/Shared.fs +++ b/Content/default/src/Shared/Shared.fs @@ -15,5 +15,5 @@ module Todo = type ITodosApi = { getTodos: unit -> Async - addTodo: Todo -> Async + addTodo: Todo -> Async } \ No newline at end of file diff --git a/Content/default/tests/Client/Client.Tests.fs b/Content/default/tests/Client/Client.Tests.fs index c1a83d42..4d897da5 100644 --- a/Content/default/tests/Client/Client.Tests.fs +++ b/Content/default/tests/Client/Client.Tests.fs @@ -12,8 +12,7 @@ let client = <| fun _ -> let newTodo = Todo.create "new todo" let model, _ = init () - let model, _ = update (LoadTodos (Finished [])) model - let model, _ = update (SaveTodo(Finished newTodo)) model + let model, _ = update (SaveTodo(Finished [ newTodo ])) model Expect.equal (model.Todos |> RemoteData.map _.Length |> RemoteData.defaultValue 0) @@ -30,13 +29,13 @@ let client = let all = testList "All" [ -//-:cnd:noEmit + //-:cnd:noEmit #if FABLE_COMPILER // This preprocessor directive makes editor happy Shared.Tests.shared #endif -//+:cnd:noEmit + //+:cnd:noEmit client ] [] -let main _ = Mocha.runTests all +let main _ = Mocha.runTests all \ No newline at end of file