2017-05-02 02:27:01 -04:00
|
|
|
module View.App exposing (view)
|
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Html.Keyed as Keyed
|
|
|
|
import Html.Lazy as Lazy
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
import Mastodon.Model exposing (..)
|
|
|
|
import Types exposing (..)
|
|
|
|
import View.Account exposing (accountFollowView, accountTimelineView)
|
|
|
|
import View.Auth exposing (authView)
|
|
|
|
import View.Common as Common
|
|
|
|
import View.Draft exposing (draftView)
|
|
|
|
import View.Error exposing (errorsListView)
|
|
|
|
import View.Events exposing (..)
|
|
|
|
import View.Notification exposing (notificationListView)
|
|
|
|
import View.Settings exposing (settingsView)
|
|
|
|
import View.Status exposing (statusView, statusActionsView, statusEntryView)
|
|
|
|
import View.Thread exposing (threadView)
|
|
|
|
import View.Viewer exposing (viewerView)
|
|
|
|
|
|
|
|
|
|
|
|
type alias CurrentUser =
|
|
|
|
Account
|
|
|
|
|
|
|
|
|
|
|
|
type alias CurrentUserRelation =
|
|
|
|
Maybe Relationship
|
|
|
|
|
|
|
|
|
2017-05-05 11:26:49 -04:00
|
|
|
timelineView : ( String, String, CurrentUser, Timeline ) -> Html Msg
|
|
|
|
timelineView ( label, iconName, currentUser, timeline ) =
|
2017-05-02 02:27:01 -04:00
|
|
|
let
|
|
|
|
keyedEntry status =
|
2017-05-05 11:26:49 -04:00
|
|
|
( toString id, statusEntryView timeline.id "" currentUser status )
|
|
|
|
|
|
|
|
entries =
|
|
|
|
List.map keyedEntry timeline.statuses
|
2017-05-02 02:27:01 -04:00
|
|
|
in
|
|
|
|
div [ class "col-md-3 column" ]
|
|
|
|
[ div [ class "panel panel-default" ]
|
|
|
|
[ a
|
2017-05-05 11:26:49 -04:00
|
|
|
[ href "", onClickWithPreventAndStop <| ScrollColumn ScrollTop timeline.id ]
|
2017-05-02 02:27:01 -04:00
|
|
|
[ div [ class "panel-heading" ] [ Common.icon iconName, text label ] ]
|
2017-05-05 11:26:49 -04:00
|
|
|
, Keyed.ul [ id timeline.id, class "list-group timeline" ] <|
|
|
|
|
(entries ++ [ ( "load-more", Common.loadMoreBtn timeline ) ])
|
2017-05-02 02:27:01 -04:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2017-05-05 11:26:49 -04:00
|
|
|
userTimelineView : CurrentUser -> Timeline -> Html Msg
|
|
|
|
userTimelineView currentUser timeline =
|
|
|
|
Lazy.lazy timelineView
|
|
|
|
( "Home timeline"
|
|
|
|
, "home"
|
|
|
|
, currentUser
|
|
|
|
, timeline
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
localTimelineView : CurrentUser -> Timeline -> Html Msg
|
|
|
|
localTimelineView currentUser timeline =
|
|
|
|
Lazy.lazy timelineView
|
|
|
|
( "Local timeline"
|
|
|
|
, "th-large"
|
|
|
|
, currentUser
|
|
|
|
, timeline
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
globalTimelineView : CurrentUser -> Timeline -> Html Msg
|
|
|
|
globalTimelineView currentUser timeline =
|
|
|
|
Lazy.lazy timelineView
|
|
|
|
( "Global timeline"
|
|
|
|
, "globe"
|
|
|
|
, currentUser
|
|
|
|
, timeline
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-05-02 02:27:01 -04:00
|
|
|
sidebarView : Model -> Html Msg
|
|
|
|
sidebarView model =
|
|
|
|
div [ class "col-md-3 column" ]
|
|
|
|
[ Lazy.lazy draftView model
|
|
|
|
, Lazy.lazy settingsView model
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
homepageView : Model -> Html Msg
|
|
|
|
homepageView model =
|
|
|
|
case model.currentUser of
|
|
|
|
Nothing ->
|
|
|
|
text ""
|
|
|
|
|
|
|
|
Just currentUser ->
|
|
|
|
div [ class "row" ]
|
|
|
|
[ Lazy.lazy sidebarView model
|
2017-05-05 11:26:49 -04:00
|
|
|
, userTimelineView currentUser model.userTimeline
|
2017-05-02 02:27:01 -04:00
|
|
|
, Lazy.lazy3
|
|
|
|
notificationListView
|
|
|
|
currentUser
|
|
|
|
model.notificationFilter
|
|
|
|
model.notifications
|
|
|
|
, case model.currentView of
|
|
|
|
LocalTimelineView ->
|
2017-05-05 11:26:49 -04:00
|
|
|
localTimelineView currentUser model.localTimeline
|
2017-05-02 02:27:01 -04:00
|
|
|
|
|
|
|
GlobalTimelineView ->
|
2017-05-05 11:26:49 -04:00
|
|
|
globalTimelineView currentUser model.globalTimeline
|
2017-05-02 02:27:01 -04:00
|
|
|
|
|
|
|
AccountView account ->
|
|
|
|
accountTimelineView
|
|
|
|
currentUser
|
|
|
|
model.accountTimeline
|
|
|
|
model.accountRelationship
|
|
|
|
account
|
|
|
|
|
|
|
|
AccountFollowersView account followers ->
|
|
|
|
accountFollowView
|
|
|
|
currentUser
|
|
|
|
model.accountFollowers
|
|
|
|
model.accountRelationships
|
|
|
|
model.accountRelationship
|
|
|
|
account
|
|
|
|
|
|
|
|
AccountFollowingView account following ->
|
|
|
|
accountFollowView
|
|
|
|
currentUser
|
|
|
|
model.accountFollowing
|
|
|
|
model.accountRelationships
|
|
|
|
model.accountRelationship
|
|
|
|
account
|
|
|
|
|
|
|
|
ThreadView thread ->
|
|
|
|
threadView currentUser thread
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
view : Model -> Html Msg
|
|
|
|
view model =
|
|
|
|
div [ class "container-fluid" ]
|
|
|
|
[ errorsListView model
|
|
|
|
, case model.client of
|
|
|
|
Just client ->
|
|
|
|
homepageView model
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
authView model
|
|
|
|
, case model.viewer of
|
|
|
|
Just viewer ->
|
|
|
|
viewerView viewer
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
text ""
|
|
|
|
]
|