diff --git a/public/index.html b/public/index.html index 0a10d30..3953542 100644 --- a/public/index.html +++ b/public/index.html @@ -17,16 +17,20 @@ diff --git a/src/Command.elm b/src/Command.elm index 07590d0..e62d7ea 100644 --- a/src/Command.elm +++ b/src/Command.elm @@ -26,6 +26,7 @@ module Command , focusId , scrollColumnToTop , scrollColumnToBottom + , scrollToThreadStatus , searchAccounts ) @@ -329,3 +330,8 @@ scrollColumnToTop column = scrollColumnToBottom : String -> Cmd Msg scrollColumnToBottom column = Task.attempt (always NoOp) <| Dom.Scroll.toBottom column + + +scrollToThreadStatus : String -> Cmd Msg +scrollToThreadStatus cssId = + Ports.scrollIntoView <| "thread-status-" ++ cssId diff --git a/src/Model.elm b/src/Model.elm index a8143bb..0f6b53b 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -524,7 +524,7 @@ processMastodonEvent msg model = case result of Ok context -> { model | currentView = ThreadView (Thread status context) } - ! [ Command.scrollColumnToBottom "thread" ] + ! [ Command.scrollToThreadStatus <| toString status.id ] Err error -> { model diff --git a/src/Ports.elm b/src/Ports.elm index 0c3f29f..c22d78d 100644 --- a/src/Ports.elm +++ b/src/Ports.elm @@ -1,4 +1,10 @@ -port module Ports exposing (saveRegistration, saveClient, setStatus) +port module Ports + exposing + ( saveRegistration + , scrollIntoView + , saveClient + , setStatus + ) port saveRegistration : String -> Cmd msg @@ -8,3 +14,6 @@ port saveClient : String -> Cmd msg port setStatus : { id : String, status : String } -> Cmd msg + + +port scrollIntoView : String -> Cmd msg diff --git a/src/View/Status.elm b/src/View/Status.elm index 216fb26..b803367 100644 --- a/src/View/Status.elm +++ b/src/View/Status.elm @@ -188,8 +188,15 @@ statusEntryView context className currentUser status = _ -> "" + + liAttributes = + [ class <| "list-group-item " ++ className ++ " " ++ nsfwClass ] + ++ if context == "thread" then + [ id <| "thread-status-" ++ (toString status.id) ] + else + [] in - li [ class <| "list-group-item " ++ className ++ " " ++ nsfwClass ] + li liAttributes [ Lazy.lazy2 statusView context status , Lazy.lazy2 statusActionsView status currentUser ]