mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-02 13:32:51 +00:00
Drop deferred message if user clicked away
This commit is contained in:
parent
284c42aec6
commit
72048b9b34
@ -98,7 +98,7 @@ type Msg
|
|||||||
| KeyUpMsg (Maybe KeyCode)
|
| KeyUpMsg (Maybe KeyCode)
|
||||||
| SetContentOnly String
|
| SetContentOnly String
|
||||||
| ScrollResult (Result Dom.Error ())
|
| ScrollResult (Result Dom.Error ())
|
||||||
| ClearItemDetailId
|
| ClearItemDetailId (Maybe String)
|
||||||
|
|
||||||
|
|
||||||
type SearchType
|
type SearchType
|
||||||
|
@ -251,12 +251,18 @@ update mId key flags settings msg model =
|
|||||||
ScrollResult _ ->
|
ScrollResult _ ->
|
||||||
let
|
let
|
||||||
cmd =
|
cmd =
|
||||||
Process.sleep 800 |> Task.perform (always ClearItemDetailId)
|
Process.sleep 800 |> Task.perform (always (ClearItemDetailId mId))
|
||||||
in
|
in
|
||||||
withSub ( model, cmd )
|
withSub ( model, cmd )
|
||||||
|
|
||||||
ClearItemDetailId ->
|
ClearItemDetailId id ->
|
||||||
withSub ( model, Page.set key (HomePage Nothing) )
|
-- if user clicks quickly away (e.g. on another item), the
|
||||||
|
-- deferred command should be ignored
|
||||||
|
if mId == id then
|
||||||
|
noSub ( model, Page.set key (HomePage Nothing) )
|
||||||
|
|
||||||
|
else
|
||||||
|
noSub ( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -328,3 +334,8 @@ withSub ( m, c ) =
|
|||||||
(Time.every 500 (\_ -> UpdateThrottle))
|
(Time.every 500 (\_ -> UpdateThrottle))
|
||||||
m.throttle
|
m.throttle
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
noSub : ( Model, Cmd Msg ) -> ( Model, Cmd Msg, Sub Msg )
|
||||||
|
noSub ( m, c ) =
|
||||||
|
( m, c, Sub.none )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user