Encode ws messages as JSON

This commit is contained in:
eikek
2021-11-11 21:55:31 +01:00
parent d0f3d54060
commit cf933b60a7
10 changed files with 99 additions and 46 deletions

View File

@ -19,6 +19,7 @@ import Api.Model.VersionInfo exposing (VersionInfo)
import Browser exposing (UrlRequest)
import Browser.Navigation exposing (Key)
import Data.Flags exposing (Flags)
import Data.ServerEvent exposing (ServerEvent)
import Data.UiSettings exposing (StoredUiSettings, UiSettings)
import Data.UiTheme exposing (UiTheme)
import Http
@ -192,7 +193,7 @@ type Msg
| SetLanguage UiLanguage
| ClientSettingsSaveResp UiSettings (Result Http.Error BasicResult)
| ReceiveBrowserSettings StoredUiSettings
| ReceiveWsMessage String
| ReceiveWsMessage (Result String ServerEvent)
| ToggleShowNewItemsArrived

View File

@ -310,12 +310,8 @@ updateWithSub msg model =
updateUserSettings texts lm model
ReceiveWsMessage data ->
let
se =
Data.ServerEvent.fromString data
in
case se of
Just ItemProcessed ->
case data of
Ok ItemProcessed ->
let
newModel =
{ model | showNewItemsArrived = True }
@ -327,7 +323,10 @@ updateWithSub msg model =
_ ->
( newModel, Cmd.none, Sub.none )
Nothing ->
Ok (JobsWaiting n) ->
( model, Cmd.none, Sub.none )
Err err ->
( model, Cmd.none, Sub.none )
ToggleShowNewItemsArrived ->