2017-05-25 17:07:17 -04:00
|
|
|
module View.Mutes exposing (mutesView)
|
|
|
|
|
|
|
|
import Html exposing (..)
|
|
|
|
import Html.Attributes exposing (..)
|
|
|
|
import Html.Events exposing (..)
|
|
|
|
import Html.Keyed as Keyed
|
|
|
|
import Mastodon.Helper exposing (..)
|
|
|
|
import Mastodon.Model exposing (..)
|
|
|
|
import Types exposing (..)
|
|
|
|
import View.Common as Common
|
2017-05-29 10:28:01 -04:00
|
|
|
import View.Timeline exposing (contextualTimelineMenu, topScrollableColumn)
|
2017-05-25 17:07:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
type alias CurrentUser =
|
|
|
|
Maybe Account
|
|
|
|
|
|
|
|
|
|
|
|
muteView : CurrentUser -> Account -> Html Msg
|
|
|
|
muteView currentUser account =
|
|
|
|
let
|
|
|
|
( isCurrentUser, entryClass ) =
|
|
|
|
case currentUser of
|
|
|
|
Just currentUser ->
|
|
|
|
if sameAccount account currentUser then
|
|
|
|
( True, "active" )
|
|
|
|
else
|
|
|
|
( False, "" )
|
|
|
|
|
|
|
|
Nothing ->
|
|
|
|
( False, "" )
|
|
|
|
in
|
|
|
|
li [ class <| "list-group-item status " ++ entryClass ]
|
|
|
|
[ div [ class "follow-entry" ]
|
|
|
|
[ Common.accountAvatarLink False account
|
|
|
|
, div [ class "userinfo" ]
|
|
|
|
[ strong []
|
|
|
|
[ a
|
2017-11-29 08:06:08 -05:00
|
|
|
[ href <| "#account/" ++ account.id ]
|
2017-05-25 17:07:17 -04:00
|
|
|
[ text <|
|
|
|
|
if account.display_name /= "" then
|
|
|
|
account.display_name
|
|
|
|
else
|
|
|
|
account.username
|
|
|
|
]
|
|
|
|
]
|
|
|
|
, br [] []
|
|
|
|
, text <| "@" ++ account.acct
|
|
|
|
]
|
|
|
|
, button
|
|
|
|
[ class "btn btn-default btn-mute btn-primary"
|
|
|
|
, title "Unmute"
|
|
|
|
, onClick <| Unmute account
|
|
|
|
]
|
|
|
|
[ Common.icon "volume-up" ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
mutesView : Model -> Html Msg
|
2017-05-29 10:28:01 -04:00
|
|
|
mutesView { currentUser, currentView, mutes, location } =
|
2017-05-25 17:07:17 -04:00
|
|
|
let
|
|
|
|
keyedEntry account =
|
2017-11-29 08:06:08 -05:00
|
|
|
( account.id
|
2017-05-29 10:28:01 -04:00
|
|
|
, muteView currentUser account
|
2017-05-25 17:07:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
entries =
|
2017-05-29 10:28:01 -04:00
|
|
|
List.map keyedEntry mutes.entries
|
2017-05-25 17:07:17 -04:00
|
|
|
in
|
2017-05-29 10:28:01 -04:00
|
|
|
topScrollableColumn ( "Mutes", "volume-off", mutes.id ) <|
|
|
|
|
div []
|
|
|
|
[ contextualTimelineMenu location.hash
|
|
|
|
, if (not mutes.loading && List.length mutes.entries == 0) then
|
|
|
|
p [ class "empty-timeline-text" ] [ text "Nobody's muted yet." ]
|
2017-05-25 17:07:17 -04:00
|
|
|
else
|
|
|
|
Keyed.ul [ id "mutes-timeline", class "list-group timeline" ] <|
|
2017-05-29 10:28:01 -04:00
|
|
|
(entries ++ [ ( "load-more", Common.loadMoreBtn mutes ) ])
|
2017-05-25 17:07:17 -04:00
|
|
|
]
|