mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 19:08:26 +00:00
Fix browser back button to restore scroll state
Removes the url parameter that was used to identify the card to scroll to and instead use the id from the internal model.
This commit is contained in:
@ -41,6 +41,7 @@ type alias Model =
|
||||
, searchTypeForm : SearchType
|
||||
, contentOnlySearch : Maybe String
|
||||
, dragDropData : DD.DragDropData
|
||||
, scrollToCard : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -70,6 +71,7 @@ init flags =
|
||||
, contentOnlySearch = Nothing
|
||||
, dragDropData =
|
||||
DD.DragDropData DD.init Nothing
|
||||
, scrollToCard = Nothing
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +100,7 @@ type Msg
|
||||
| KeyUpMsg (Maybe KeyCode)
|
||||
| SetContentOnly String
|
||||
| ScrollResult (Result Dom.Error ())
|
||||
| ClearItemDetailId (Maybe String)
|
||||
| ClearItemDetailId
|
||||
|
||||
|
||||
type SearchType
|
||||
|
@ -243,18 +243,12 @@ update mId key flags settings msg model =
|
||||
ScrollResult _ ->
|
||||
let
|
||||
cmd =
|
||||
Process.sleep 800 |> Task.perform (always (ClearItemDetailId mId))
|
||||
Process.sleep 800 |> Task.perform (always ClearItemDetailId)
|
||||
in
|
||||
withSub ( model, cmd )
|
||||
|
||||
ClearItemDetailId id ->
|
||||
-- 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 )
|
||||
ClearItemDetailId ->
|
||||
noSub ( { model | scrollToCard = Nothing }, Cmd.none )
|
||||
|
||||
|
||||
|
||||
@ -269,7 +263,10 @@ scrollToCard mId model =
|
||||
in
|
||||
case mId of
|
||||
Just id ->
|
||||
( model, Task.attempt ScrollResult (scroll id), Sub.none )
|
||||
( { model | scrollToCard = mId }
|
||||
, Task.attempt ScrollResult (scroll id)
|
||||
, Sub.none
|
||||
)
|
||||
|
||||
Nothing ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
@ -82,7 +82,7 @@ view current flags settings model =
|
||||
]
|
||||
[ viewSearchBar flags model
|
||||
, Html.map ItemCardListMsg
|
||||
(Comp.ItemCardList.view current settings model.itemListModel)
|
||||
(Comp.ItemCardList.view model.scrollToCard settings model.itemListModel)
|
||||
]
|
||||
, div
|
||||
[ classList
|
||||
|
@ -25,7 +25,7 @@ update referrer flags msg model =
|
||||
AuthResp (Ok lr) ->
|
||||
let
|
||||
gotoRef =
|
||||
Maybe.withDefault (HomePage Nothing) referrer |> Page.goto
|
||||
Maybe.withDefault HomePage referrer |> Page.goto
|
||||
in
|
||||
if lr.success then
|
||||
( { model | result = Just lr, password = "" }, Cmd.batch [ setAccount lr, gotoRef ], Just lr )
|
||||
|
@ -77,7 +77,7 @@ renderSuccessMsg public _ =
|
||||
else
|
||||
p []
|
||||
[ text "Your files have been successfully uploaded. They are now being processed. Check the "
|
||||
, a [ class "ui link", Page.href (HomePage Nothing) ]
|
||||
, a [ class "ui link", Page.href HomePage ]
|
||||
[ text "Items page"
|
||||
]
|
||||
, text " later where the files will arrive eventually. Or go to the "
|
||||
|
Reference in New Issue
Block a user