mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-24 03:18:26 +00:00
Replace js code with proper elm using elm-scroll package
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
module Page.ItemDetail.Data exposing (Model, Msg(..), emptyModel)
|
||||
|
||||
import Api.Model.ItemDetail exposing (ItemDetail)
|
||||
import Browser.Dom as Dom
|
||||
import Comp.ItemDetail
|
||||
import Comp.ItemDetail.Update
|
||||
import Http
|
||||
@ -21,3 +22,4 @@ type Msg
|
||||
= Init String
|
||||
| ItemDetailMsg Comp.ItemDetail.Update.Msg
|
||||
| ItemResp (Result Http.Error ItemDetail)
|
||||
| ScrollResult (Result Dom.Error ())
|
||||
|
@ -6,7 +6,8 @@ import Comp.ItemDetail
|
||||
import Comp.ItemDetail.Update
|
||||
import Data.Flags exposing (Flags)
|
||||
import Page.ItemDetail.Data exposing (Model, Msg(..))
|
||||
import Ports
|
||||
import Scroll
|
||||
import Task
|
||||
|
||||
|
||||
update : Nav.Key -> Flags -> Maybe String -> Msg -> Model -> ( Model, Cmd Msg, Sub Msg )
|
||||
@ -16,12 +17,15 @@ update key flags next msg model =
|
||||
let
|
||||
( lm, lc, ls ) =
|
||||
Comp.ItemDetail.update key flags next Comp.ItemDetail.Update.Init model.detail
|
||||
|
||||
task =
|
||||
Scroll.scroll "main-content" 0 0 0 0
|
||||
in
|
||||
( { model | detail = lm }
|
||||
, Cmd.batch
|
||||
[ Api.itemDetail flags id ItemResp
|
||||
, Cmd.map ItemDetailMsg lc
|
||||
, Ports.scrollToTop ()
|
||||
, Task.attempt ScrollResult task
|
||||
]
|
||||
, Sub.map ItemDetailMsg ls
|
||||
)
|
||||
@ -45,3 +49,6 @@ update key flags next msg model =
|
||||
|
||||
ItemResp (Err _) ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
||||
ScrollResult _ ->
|
||||
( model, Cmd.none, Sub.none )
|
||||
|
Reference in New Issue
Block a user