Add more scroll events when navigating timelines.
This commit is contained in:
parent
059b2726e6
commit
8bb9adb307
@ -22,14 +22,20 @@ module Command
|
||||
, unfavouriteStatus
|
||||
, follow
|
||||
, unfollow
|
||||
, focusId
|
||||
, scrollColumnToTop
|
||||
, scrollColumnToBottom
|
||||
)
|
||||
|
||||
import Dom
|
||||
import Dom.Scroll
|
||||
import Json.Encode as Encode
|
||||
import Mastodon.Model exposing (..)
|
||||
import Mastodon.Encoder
|
||||
import Mastodon.Http
|
||||
import Navigation
|
||||
import Ports
|
||||
import Task
|
||||
import Types exposing (..)
|
||||
|
||||
|
||||
@ -287,3 +293,18 @@ unfollow client id =
|
||||
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
|
||||
|
||||
focusId : String -> Cmd Msg
|
||||
focusId id =
|
||||
Dom.focus id |> Task.attempt (always NoOp)
|
||||
|
||||
|
||||
scrollColumnToTop : String -> Cmd Msg
|
||||
scrollColumnToTop column =
|
||||
Task.attempt (always NoOp) <| Dom.Scroll.toTop column
|
||||
|
||||
|
||||
scrollColumnToBottom : String -> Cmd Msg
|
||||
scrollColumnToBottom column =
|
||||
Task.attempt (always NoOp) <| Dom.Scroll.toBottom column
|
||||
|
@ -1,14 +1,11 @@
|
||||
module Model exposing (..)
|
||||
|
||||
import Command
|
||||
import Dom
|
||||
import Dom.Scroll
|
||||
import Navigation
|
||||
import Mastodon.Decoder
|
||||
import Mastodon.Helper
|
||||
import Mastodon.Model exposing (..)
|
||||
import Mastodon.WebSocket
|
||||
import Task
|
||||
import Types exposing (..)
|
||||
|
||||
|
||||
@ -224,7 +221,7 @@ updateDraft draftMsg currentUser draft =
|
||||
Just status.spoiler_text
|
||||
, visibility = status.visibility
|
||||
}
|
||||
! [ Dom.focus "status" |> Task.attempt (always NoOp) ]
|
||||
! [ Command.focusId "status" ]
|
||||
|
||||
|
||||
updateViewer : ViewerMsg -> Maybe Viewer -> ( Maybe Viewer, Cmd Msg )
|
||||
@ -286,7 +283,8 @@ processMastodonEvent msg model =
|
||||
ContextLoaded status result ->
|
||||
case result of
|
||||
Ok context ->
|
||||
{ model | currentView = ThreadView (Thread status context) } ! []
|
||||
{ model | currentView = ThreadView (Thread status context) }
|
||||
! [ Command.scrollColumnToBottom "thread" ]
|
||||
|
||||
Err error ->
|
||||
{ model
|
||||
@ -352,7 +350,8 @@ processMastodonEvent msg model =
|
||||
{ model | errors = (errorText error) :: model.errors } ! []
|
||||
|
||||
StatusPosted _ ->
|
||||
{ model | draft = defaultDraft } ! []
|
||||
{ model | draft = defaultDraft }
|
||||
! [ Command.scrollColumnToTop "home" ]
|
||||
|
||||
StatusDeleted result ->
|
||||
case result of
|
||||
@ -644,8 +643,11 @@ update msg model =
|
||||
}
|
||||
! []
|
||||
|
||||
ScrollColumn context ->
|
||||
model ! [ Task.attempt (always NoOp) <| Dom.Scroll.toTop context ]
|
||||
ScrollColumn ScrollTop column ->
|
||||
model ! [ Command.scrollColumnToTop column ]
|
||||
|
||||
ScrollColumn ScrollBottom column ->
|
||||
model ! [ Command.scrollColumnToBottom column ]
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
|
@ -70,7 +70,7 @@ type Msg
|
||||
| ReblogStatus Int
|
||||
| Register
|
||||
| RemoveFavorite Int
|
||||
| ScrollColumn String
|
||||
| ScrollColumn ScrollDirection String
|
||||
| ServerChange String
|
||||
| SubmitDraft
|
||||
| UnfollowAccount Int
|
||||
@ -92,6 +92,16 @@ type alias AccountViewInfo =
|
||||
}
|
||||
|
||||
|
||||
type CurrentView
|
||||
= -- Basically, what we should be displaying in the fourth column
|
||||
AccountFollowersView Account (List Account)
|
||||
| AccountFollowingView Account (List Account)
|
||||
| AccountView Account
|
||||
| GlobalTimelineView
|
||||
| LocalTimelineView
|
||||
| ThreadView Thread
|
||||
|
||||
|
||||
type alias Draft =
|
||||
{ status : String
|
||||
, in_reply_to : Maybe Status
|
||||
@ -101,6 +111,11 @@ type alias Draft =
|
||||
}
|
||||
|
||||
|
||||
type ScrollDirection
|
||||
= ScrollTop
|
||||
| ScrollBottom
|
||||
|
||||
|
||||
type alias Thread =
|
||||
{ status : Status
|
||||
, context : Context
|
||||
@ -113,16 +128,6 @@ type alias Viewer =
|
||||
}
|
||||
|
||||
|
||||
type CurrentView
|
||||
= -- Basically, what we should be displaying in the fourth column
|
||||
AccountFollowersView Account (List Account)
|
||||
| AccountFollowingView Account (List Account)
|
||||
| AccountView Account
|
||||
| GlobalTimelineView
|
||||
| LocalTimelineView
|
||||
| ThreadView Thread
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ server : String
|
||||
, registration : Maybe AppRegistration
|
||||
|
10
src/View.elm
10
src/View.elm
@ -178,10 +178,6 @@ statusView context ({ account, content, media_attachments, reblog, mentions } as
|
||||
let
|
||||
accountLinkAttributes =
|
||||
[ href account.url
|
||||
|
||||
-- When clicking on a status, we should not let the browser
|
||||
-- redirect to a new page. That's why we're preventing the default
|
||||
-- behavior here
|
||||
, onClickWithPreventAndStop (LoadAccount account.id)
|
||||
]
|
||||
in
|
||||
@ -433,7 +429,7 @@ timelineView label iconName context currentUser statuses =
|
||||
div [ class "col-md-3 column" ]
|
||||
[ div [ class "panel panel-default" ]
|
||||
[ a
|
||||
[ href "", onClickWithPreventAndStop <| ScrollColumn context ]
|
||||
[ href "", onClickWithPreventAndStop <| ScrollColumn ScrollTop context ]
|
||||
[ div [ class "panel-heading" ] [ icon iconName, text label ] ]
|
||||
, ul [ id context, class "list-group timeline" ] <|
|
||||
List.map (statusEntryView context "" currentUser) statuses
|
||||
@ -509,7 +505,7 @@ notificationListView currentUser notifications =
|
||||
div [ class "col-md-3 column" ]
|
||||
[ div [ class "panel panel-default" ]
|
||||
[ a
|
||||
[ href "", onClickWithPreventAndStop <| ScrollColumn "notifications" ]
|
||||
[ href "", onClickWithPreventAndStop <| ScrollColumn ScrollTop "notifications" ]
|
||||
[ div [ class "panel-heading" ] [ icon "bell", text "Notifications" ] ]
|
||||
, ul [ id "notifications", class "list-group timeline" ] <|
|
||||
List.map (notificationEntryView currentUser) notifications
|
||||
@ -692,7 +688,7 @@ threadView currentUser thread =
|
||||
div [ class "col-md-3 column" ]
|
||||
[ div [ class "panel panel-default" ]
|
||||
[ closeablePanelheading "list" "Thread" CloseThread
|
||||
, ul [ class "list-group timeline" ] <|
|
||||
, ul [ id "thread", class "list-group timeline" ] <|
|
||||
List.map threadEntry statuses
|
||||
]
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user