Add websockets and notify frontend when an item is processed

This commit is contained in:
eikek
2021-11-06 21:32:07 +01:00
parent f38d520a1d
commit 3e58d97f72
17 changed files with 243 additions and 114 deletions

View File

@ -190,6 +190,7 @@ type Msg
| SetLanguage UiLanguage
| ClientSettingsSaveResp UiSettings (Result Http.Error BasicResult)
| ReceiveBrowserSettings StoredUiSettings
| ReceiveWsMessage String
defaultPage : Flags -> Page

View File

@ -308,6 +308,13 @@ updateWithSub msg model =
in
updateUserSettings texts lm model
ReceiveWsMessage data ->
let
_ =
Debug.log "WS-msg" data
in
( model, Cmd.none, Sub.none )
applyClientSettings : Messages -> Model -> UiSettings -> ( Model, Cmd Msg, Sub Msg )
applyClientSettings texts model settings =

View File

@ -93,4 +93,5 @@ subscriptions model =
Sub.batch
[ model.subs
, Ports.receiveUiSettings ReceiveBrowserSettings
, Ports.receiveWsMessage ReceiveWsMessage
]

View File

@ -11,6 +11,7 @@ port module Ports exposing
, printElement
, receiveCheckQueryResult
, receiveUiSettings
, receiveWsMessage
, removeAccount
, requestUiSettings
, setAccount
@ -55,6 +56,15 @@ and calls the print dialog.
port printElement : String -> Cmd msg
{-| Receives messages from the websocket.
-}
port receiveWsMessage : (String -> msg) -> Sub msg
--- Higher level functions based on ports
setUiTheme : UiTheme -> Cmd msg
setUiTheme theme =
internalSetUiTheme (Data.UiTheme.toString theme)