Show pinned statuses
This commit is contained in:
parent
487adc9d1f
commit
2f227355b8
@ -10,6 +10,7 @@ module Command
|
||||
, loadAccount
|
||||
, loadAccountFollowers
|
||||
, loadAccountFollowing
|
||||
, loadAccountPins
|
||||
, loadHomeTimeline
|
||||
, loadLocalTimeline
|
||||
, loadGlobalTimeline
|
||||
@ -186,6 +187,20 @@ loadAccount client accountId =
|
||||
Cmd.none
|
||||
|
||||
|
||||
loadAccountPins : Maybe Client -> String -> Maybe String -> Cmd Msg
|
||||
loadAccountPins client accountId url =
|
||||
case client of
|
||||
Just client ->
|
||||
HttpBuilder.get (Maybe.withDefault (ApiUrl.accountTimeline accountId) url)
|
||||
|> withClient client
|
||||
|> withBodyDecoder (Decode.list statusDecoder)
|
||||
|> withQueryParams [ ( "pinned", "true" ) ]
|
||||
|> send (MastodonEvent << AccountPins (url /= Nothing))
|
||||
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
|
||||
|
||||
loadAccountFollowers : Maybe Client -> String -> Maybe String -> Cmd Msg
|
||||
loadAccountFollowers client accountId url =
|
||||
case client of
|
||||
|
@ -253,6 +253,7 @@ statusDecoder =
|
||||
|> Pipe.required "uri" Decode.string
|
||||
|> Pipe.required "url" (Decode.nullable Decode.string)
|
||||
|> Pipe.required "visibility" Decode.string
|
||||
|> Pipe.optional "pinned" Decode.bool False -- Not a real value, used to show pinned indicator
|
||||
|
||||
|
||||
webSocketEventDecoder : Decode.Decoder WebSocketMessage
|
||||
|
@ -260,6 +260,7 @@ type alias Status =
|
||||
, uri : String
|
||||
, url : Maybe String
|
||||
, visibility : String
|
||||
, pinned : Bool -- Not a real value, used to show pinned indicator
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,7 @@ type MastodonMsg
|
||||
| AccountFollowing Bool (MastodonResult (List Account))
|
||||
| AccountBlocked Account (MastodonResult Relationship)
|
||||
| AccountMuted Account (MastodonResult Relationship)
|
||||
| AccountPins Bool (MastodonResult (List Status))
|
||||
| AccountReceived (MastodonResult Account)
|
||||
| AccountRelationship (MastodonResult (List Relationship))
|
||||
| AccountRelationships (MastodonResult (List Relationship))
|
||||
@ -135,6 +136,7 @@ type Msg
|
||||
|
||||
type alias AccountInfo =
|
||||
{ account : Maybe Account
|
||||
, pins : List Status
|
||||
, timeline : Timeline Status
|
||||
, followers : Timeline Account
|
||||
, following : Timeline Account
|
||||
|
@ -7,6 +7,7 @@ import Update.Timeline
|
||||
empty : AccountInfo
|
||||
empty =
|
||||
{ account = Nothing
|
||||
, pins = []
|
||||
, timeline = Update.Timeline.empty "account-timeline"
|
||||
, followers = Update.Timeline.empty "account-followers"
|
||||
, following = Update.Timeline.empty "account-following"
|
||||
|
@ -275,6 +275,20 @@ update msg ({ accountInfo, search } as model) =
|
||||
Err error ->
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
|
||||
AccountPins append result ->
|
||||
case result of
|
||||
Ok { decoded, links } ->
|
||||
{ model
|
||||
| accountInfo =
|
||||
{ accountInfo
|
||||
| pins = decoded
|
||||
}
|
||||
}
|
||||
! []
|
||||
|
||||
Err error ->
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
|
||||
AccountTimeline append result ->
|
||||
case result of
|
||||
Ok { decoded, links } ->
|
||||
|
@ -96,6 +96,7 @@ update ({ accountInfo } as model) =
|
||||
, accountInfo = Update.AccountInfo.empty
|
||||
}
|
||||
! [ Command.loadAccount (List.head model.clients) accountId
|
||||
, Command.loadAccountPins (List.head model.clients) accountId Nothing
|
||||
, Command.loadAccountTimeline (List.head model.clients) accountId Nothing
|
||||
]
|
||||
|
||||
|
@ -175,8 +175,8 @@ accountFollowView view currentUser accountInfo =
|
||||
text ""
|
||||
|
||||
|
||||
accountTimelineView : CurrentUser -> AccountInfo -> Html Msg
|
||||
accountTimelineView currentUser accountInfo =
|
||||
accountTimelineView : CurrentUser -> AccountInfo -> Bool -> Html Msg
|
||||
accountTimelineView currentUser accountInfo pins =
|
||||
let
|
||||
keyedEntry status =
|
||||
( extractStatusId status.id
|
||||
@ -185,11 +185,17 @@ accountTimelineView currentUser accountInfo =
|
||||
|
||||
entries =
|
||||
List.map keyedEntry accountInfo.timeline.entries
|
||||
|
||||
setPin status =
|
||||
{ status | pinned = True }
|
||||
|
||||
pins =
|
||||
List.map keyedEntry (List.map setPin accountInfo.pins)
|
||||
in
|
||||
case accountInfo.account of
|
||||
Just account ->
|
||||
Keyed.ul [ id accountInfo.timeline.id, class "list-group" ] <|
|
||||
(entries ++ [ ( "load-more", Common.loadMoreBtn accountInfo.timeline ) ])
|
||||
List.append pins (entries ++ [ ( "load-more", Common.loadMoreBtn accountInfo.timeline ) ])
|
||||
|
||||
Nothing ->
|
||||
text ""
|
||||
@ -341,10 +347,10 @@ accountView subView currentUser accountInfo =
|
||||
, counterLinks subView account
|
||||
, case subView of
|
||||
AccountStatusesView ->
|
||||
accountTimelineView currentUser accountInfo
|
||||
accountTimelineView currentUser accountInfo True
|
||||
|
||||
AccountStatusesRepliesView ->
|
||||
accountTimelineView currentUser accountInfo
|
||||
accountTimelineView currentUser accountInfo False
|
||||
|
||||
_ ->
|
||||
accountFollowView subView currentUser accountInfo
|
||||
|
@ -205,10 +205,19 @@ statusEntryView context className currentUser status =
|
||||
|
||||
|
||||
statusView : String -> Status -> Html Msg
|
||||
statusView context ({ account, content, media_attachments, reblog, mentions } as status) =
|
||||
statusView context ({ account, content, media_attachments, reblog, mentions, pinned } as status) =
|
||||
let
|
||||
accountLinkAttributes =
|
||||
[ href <| "#account/" ++ account.id ]
|
||||
|
||||
pin =
|
||||
if pinned then
|
||||
p [ class "status-info" ]
|
||||
[ Common.icon "pushpin"
|
||||
, text " Pinned status"
|
||||
]
|
||||
else
|
||||
text ""
|
||||
in
|
||||
case reblog of
|
||||
Just (Reblog reblog) ->
|
||||
@ -224,7 +233,8 @@ statusView context ({ account, content, media_attachments, reblog, mentions } as
|
||||
|
||||
Nothing ->
|
||||
div [ class "status" ]
|
||||
[ Common.accountAvatarLink False account
|
||||
[ pin
|
||||
, Common.accountAvatarLink False account
|
||||
, div [ class "username" ]
|
||||
[ a accountLinkAttributes
|
||||
[ text (if account.display_name=="" then account.username else account.display_name)
|
||||
|
Loading…
Reference in New Issue
Block a user