Refresh home page on item-process event

This commit is contained in:
eikek 2021-11-06 23:35:43 +01:00
parent 3e58d97f72
commit 42767e7732
4 changed files with 53 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import App.Data exposing (..)
import Browser exposing (UrlRequest(..))
import Browser.Navigation as Nav
import Data.Flags
import Data.ServerEvent exposing (ServerEvent(..))
import Data.UiSettings exposing (UiSettings)
import Data.UiTheme
import Messages exposing (Messages)
@ -310,10 +311,20 @@ updateWithSub msg model =
ReceiveWsMessage data ->
let
_ =
Debug.log "WS-msg" data
se =
Data.ServerEvent.fromString data
in
( model, Cmd.none, Sub.none )
case se of
Just ItemProcessed ->
case model.page of
HomePage ->
updateHome texts Page.Home.Data.RefreshView model
_ ->
( model, Cmd.none, Sub.none )
Nothing ->
( model, Cmd.none, Sub.none )
applyClientSettings : Messages -> Model -> UiSettings -> ( Model, Cmd Msg, Sub Msg )

View File

@ -0,0 +1,22 @@
{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Data.ServerEvent exposing (ServerEvent(..), fromString)
type ServerEvent
= ItemProcessed
fromString : String -> Maybe ServerEvent
fromString str =
case String.toLower str of
"item-processed" ->
Just ItemProcessed
_ ->
Nothing

View File

@ -229,6 +229,7 @@ type Msg
| PublishItemsMsg Comp.PublishItems.Msg
| TogglePublishCurrentQueryView
| PublishViewMsg Comp.PublishItems.Msg
| RefreshView
type SearchType

View File

@ -227,6 +227,22 @@ update mId key flags texts settings msg model =
else
doSearch param nm
RefreshView ->
let
param =
{ flags = flags
, searchType = model.lastSearchType
, pageSize = settings.itemSearchPageSize
, offset = model.searchOffset
, scroll = False
}
in
if model.searchInProgress then
withSub ( model, Cmd.none )
else
doSearch param model
ToggleSearchMenu ->
let
nextView =