Visually indicate the last viewed item in the list

This commit is contained in:
Eike Kettner 2020-09-15 23:33:28 +02:00
parent ad110b2a05
commit 09785292e7
2 changed files with 14 additions and 5 deletions

View File

@ -97,6 +97,7 @@ type Msg
| KeyUpMsg (Maybe KeyCode) | KeyUpMsg (Maybe KeyCode)
| SetContentOnly String | SetContentOnly String
| ScrollResult (Result Dom.Error ()) | ScrollResult (Result Dom.Error ())
| ClearItemDetailId
type SearchType type SearchType

View File

@ -8,6 +8,7 @@ import Data.Flags exposing (Flags)
import Data.UiSettings exposing (UiSettings) import Data.UiSettings exposing (UiSettings)
import Page exposing (Page(..)) import Page exposing (Page(..))
import Page.Home.Data exposing (..) import Page.Home.Data exposing (..)
import Process
import Scroll import Scroll
import Task import Task
import Throttle import Throttle
@ -82,13 +83,13 @@ update mId key flags settings msg model =
m m
model.itemListModel model.itemListModel
cmd = ( cmd, id ) =
case result.selected of case result.selected of
Just item -> Just item ->
Page.set key (ItemDetailPage item.id) ( Page.set key (ItemDetailPage item.id), Just item.id )
Nothing -> Nothing ->
Cmd.none ( Cmd.none, Nothing )
in in
withSub withSub
( { model ( { model
@ -222,8 +223,15 @@ update mId key flags settings msg model =
KeyUpMsg _ -> KeyUpMsg _ ->
withSub ( model, Cmd.none ) withSub ( model, Cmd.none )
ScrollResult res -> ScrollResult _ ->
withSub ( model, Cmd.none ) let
cmd =
Process.sleep 350 |> Task.perform (always ClearItemDetailId)
in
withSub ( model, cmd )
ClearItemDetailId ->
withSub ( model, Page.set key (HomePage Nothing) )