Rather dubious struct-based stuff all plumbed through

This commit is contained in:
Smaug123
2022-11-13 23:13:04 +00:00
parent 72785eda06
commit ff59e6d7d7
8 changed files with 141 additions and 50 deletions

View File

@@ -64,7 +64,8 @@ module App =
| RegisterClientResponse.Success client ->
try
clients.Add (client, HashSet ())
with :? ArgumentException ->
with _ ->
// This is ArgumentException, but Fable can't type-test that
failwith "TODO: got a response a second time - need to handle this in the UI"
| RegisterClientResponse.NotLeader hint -> failwith "TODO: asked a non-leader, have to handle it"
)
@@ -157,7 +158,7 @@ module App =
ActionHistory = []
}
(promise { return () }, userPrefs.Value.ActionHistory)
(promise { return () }, newPrefs.ActionHistory)
||> List.fold (fun (inPromise : Promise<unit>) action ->
promise {
let! _ = inPromise

View File

@@ -402,13 +402,20 @@ module Ui =
: Result<UserPreferences<'a>, string>
=
let actionHistory =
ui.ActionHistoryList.value.Split "\n"
|> Seq.filter (not << System.String.IsNullOrEmpty)
|> Seq.map (
NetworkAction.tryParse<'a> parse None handleRegisterClientResponse handleClientDataResponse clusterSize
)
|> Result.allOkOrError
|> Result.map List.ofSeq
let arr = ResizeArray ()
for i in StringSplitEnumerator.make '\n' ui.ActionHistoryList.value do
if not (EfficientString.isEmpty i) then
NetworkAction.tryParse<'a>
parse
None
handleRegisterClientResponse
handleClientDataResponse
clusterSize
i
|> arr.Add
Result.allOkOrError arr |> Result.map List.ofSeq
match actionHistory with
| Result.Ok actionHistory ->