Merge branch 'master' of github.com:n1k0/tooty
This commit is contained in:
commit
91f5216401
|
@ -17,16 +17,20 @@
|
|||
<body>
|
||||
<script src="app.js"></script>
|
||||
<script>
|
||||
|
||||
const app = Elm.Main.fullscreen({
|
||||
client: JSON.parse(localStorage.getItem("tooty.client")),
|
||||
registration: JSON.parse(localStorage.getItem("tooty.registration"))
|
||||
});
|
||||
|
||||
app.ports.saveClient.subscribe(json => {
|
||||
localStorage.setItem("tooty.client", json);
|
||||
});
|
||||
|
||||
app.ports.saveRegistration.subscribe(json => {
|
||||
localStorage.setItem("tooty.registration", json);
|
||||
});
|
||||
|
||||
app.ports.setStatus.subscribe(function(data) {
|
||||
var element = document.getElementById(data.id);
|
||||
if (element) {
|
||||
|
@ -35,6 +39,16 @@
|
|||
element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
app.ports.scrollIntoView.subscribe(function(id) {
|
||||
requestAnimationFrame(function() {
|
||||
var element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.scrollIntoView(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue