Render app link in target thread toot.
This commit is contained in:
parent
b180cc42e3
commit
b6c858da2d
@ -120,6 +120,10 @@ li.load-more {
|
||||
background: #493438;
|
||||
}
|
||||
|
||||
span.applink {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.reblog > p:first-of-type,
|
||||
.notification > p:first-of-type {
|
||||
color: #999;
|
||||
|
@ -59,6 +59,13 @@ accountDecoder =
|
||||
|> Pipe.required "username" Decode.string
|
||||
|
||||
|
||||
applicationDecoder : Decode.Decoder Application
|
||||
applicationDecoder =
|
||||
Pipe.decode Application
|
||||
|> Pipe.required "name" Decode.string
|
||||
|> Pipe.required "website" (Decode.nullable Decode.string)
|
||||
|
||||
|
||||
attachmentDecoder : Decode.Decoder Attachment
|
||||
attachmentDecoder =
|
||||
Pipe.decode Attachment
|
||||
@ -128,6 +135,7 @@ statusDecoder : Decode.Decoder Status
|
||||
statusDecoder =
|
||||
Pipe.decode Status
|
||||
|> Pipe.required "account" accountDecoder
|
||||
|> Pipe.required "application" (Decode.nullable applicationDecoder)
|
||||
|> Pipe.required "content" Decode.string
|
||||
|> Pipe.required "created_at" Decode.string
|
||||
|> Pipe.optional "favourited" (Decode.nullable Decode.bool) Nothing
|
||||
|
@ -3,6 +3,7 @@ module Mastodon.Model
|
||||
( AccessTokenResult
|
||||
, AppRegistration
|
||||
, Account
|
||||
, Application
|
||||
, Attachment
|
||||
, Client
|
||||
, Context
|
||||
@ -90,6 +91,12 @@ type alias Account =
|
||||
}
|
||||
|
||||
|
||||
type alias Application =
|
||||
{ name : String
|
||||
, website : Maybe String
|
||||
}
|
||||
|
||||
|
||||
type alias Attachment =
|
||||
-- type_: -- "image", "video", "gifv"
|
||||
{ id : Int
|
||||
@ -163,6 +170,7 @@ type alias Relationship =
|
||||
|
||||
type alias Status =
|
||||
{ account : Account
|
||||
, application : Maybe Application
|
||||
, content : String
|
||||
, created_at : String
|
||||
, favourited : Maybe Bool
|
||||
|
@ -3,6 +3,7 @@ module View.Common
|
||||
( accountAvatar
|
||||
, accountAvatarLink
|
||||
, accountLink
|
||||
, appLink
|
||||
, closeablePanelheading
|
||||
, icon
|
||||
, justifiedButtonGroup
|
||||
@ -63,6 +64,21 @@ accountAvatarLink external account =
|
||||
[ accountAvatar avatarClass account ]
|
||||
|
||||
|
||||
appLink : String -> Maybe Application -> Html Msg
|
||||
appLink classes app =
|
||||
case app of
|
||||
Nothing ->
|
||||
text ""
|
||||
|
||||
Just { name, website } ->
|
||||
case website of
|
||||
Nothing ->
|
||||
span [ class classes ] [ text name ]
|
||||
|
||||
Just website ->
|
||||
a [ href website, target "_blank", class classes ] [ text name ]
|
||||
|
||||
|
||||
closeablePanelheading : String -> String -> String -> Msg -> Html Msg
|
||||
closeablePanelheading context iconName label onClose =
|
||||
div [ class "panel-heading" ]
|
||||
|
@ -99,7 +99,7 @@ notificationStatusView ( context, currentUser, status, { type_, accounts } ) =
|
||||
_ ->
|
||||
text ""
|
||||
, Lazy.lazy2 statusView context status
|
||||
, Lazy.lazy2 statusActionsView status currentUser
|
||||
, Lazy.lazy3 statusActionsView status currentUser False
|
||||
]
|
||||
|
||||
|
||||
|
@ -84,8 +84,8 @@ attachmentListView context { media_attachments, sensitive } =
|
||||
List.map (keyedEntry attachments) attachments
|
||||
|
||||
|
||||
statusActionsView : Status -> CurrentUser -> Html Msg
|
||||
statusActionsView status currentUser =
|
||||
statusActionsView : Status -> CurrentUser -> Bool -> Html Msg
|
||||
statusActionsView status currentUser showApp =
|
||||
let
|
||||
sourceStatus =
|
||||
Mastodon.Helper.extractReblog status
|
||||
@ -119,8 +119,7 @@ statusActionsView status currentUser =
|
||||
div [ class "btn-group actions" ]
|
||||
[ a
|
||||
[ class baseBtnClasses
|
||||
, onClickWithPreventAndStop <|
|
||||
DraftEvent (UpdateReplyTo status)
|
||||
, onClickWithPreventAndStop <| DraftEvent (UpdateReplyTo status)
|
||||
]
|
||||
[ Common.icon "share-alt" ]
|
||||
, if status.visibility == "private" then
|
||||
@ -131,20 +130,17 @@ statusActionsView status currentUser =
|
||||
[ span [ title "Direct" ] [ Common.icon "envelope" ] ]
|
||||
else
|
||||
a
|
||||
[ class reblogClasses
|
||||
, onClickWithPreventAndStop reblogEvent
|
||||
]
|
||||
[ class reblogClasses, onClickWithPreventAndStop reblogEvent ]
|
||||
[ Common.icon "fire", text (toString sourceStatus.reblogs_count) ]
|
||||
, a
|
||||
[ class favClasses
|
||||
, onClickWithPreventAndStop favEvent
|
||||
]
|
||||
[ class favClasses, onClickWithPreventAndStop favEvent ]
|
||||
[ Common.icon "star", text (toString sourceStatus.favourites_count) ]
|
||||
, if Mastodon.Helper.sameAccount sourceStatus.account currentUser then
|
||||
a
|
||||
[ class <| baseBtnClasses ++ " btn-delete"
|
||||
, href ""
|
||||
, onClickWithPreventAndStop <| AskConfirm "Are you sure you want to delete this toot?" (DeleteStatus sourceStatus.id) NoOp
|
||||
, onClickWithPreventAndStop <|
|
||||
AskConfirm "Are you sure you want to delete this toot?" (DeleteStatus sourceStatus.id) NoOp
|
||||
]
|
||||
[ Common.icon "trash" ]
|
||||
else
|
||||
@ -152,6 +148,10 @@ statusActionsView status currentUser =
|
||||
, a
|
||||
[ class baseBtnClasses, href (Maybe.withDefault "#" status.url), target "_blank" ]
|
||||
[ Common.icon "time", formatDate ]
|
||||
, if showApp then
|
||||
Common.appLink (baseBtnClasses ++ " applink") status.application
|
||||
else
|
||||
text ""
|
||||
]
|
||||
|
||||
|
||||
@ -205,7 +205,7 @@ statusEntryView context className currentUser status =
|
||||
in
|
||||
li liAttributes
|
||||
[ Lazy.lazy2 statusView context status
|
||||
, Lazy.lazy2 statusActionsView status currentUser
|
||||
, Lazy.lazy3 statusActionsView status currentUser (className == "thread-target")
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user