Make instance icons more prevalent

This commit is contained in:
Ryan Fox 2021-12-01 00:50:51 -08:00
parent afc3f3e09d
commit 592607835a
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
3 changed files with 50 additions and 24 deletions

View File

@ -107,7 +107,7 @@ followView currentUser relationship account =
] ]
] ]
, br [] [] , br [] []
, text <| "@" ++ account.acct , Common.accountAcctView True account
] ]
, muteButton currentUser relationship account , muteButton currentUser relationship account
, followButton currentUser relationship account , followButton currentUser relationship account

View File

@ -1,10 +1,12 @@
module View.Common module View.Common
exposing exposing
( accountAvatar ( accountAcctView
, accountAvatar
, accountAvatarLink , accountAvatarLink
, accountLink , accountLink
, accountLinkSmall , accountLinkSmall
, accountLinkLarge , accountLinkLarge
, instanceIconsView
, appLink , appLink
, closeablePanelheading , closeablePanelheading
, icon , icon
@ -31,20 +33,32 @@ accountAvatar avatarClass account =
img [ class avatarClass, src account.avatar ] [] img [ class avatarClass, src account.avatar ] []
accountDisplayName : Account -> String
accountDisplayName account =
if account.display_name == "" then
account.username
else
account.display_name
accountLink : Bool -> Account -> Html Msg accountLink : Bool -> Account -> Html Msg
accountLink external account = accountLink external account =
let if external then
accountHref =
if external then
target "_blank"
else
href <| "#account/" ++ account.id
in
a a
[ href account.url [ href account.url
, accountHref , target "_blank"
]
[ text <| "@" ++ account.acct
, instanceIconsView <| account.url
]
else
a
[ href account.url
, href <| "#account/" ++ account.id
]
[ text <| accountDisplayName <| account
, accountAcctView False account
] ]
[ text <| "@" ++ account.acct ]
accountLinkSmall : Bool -> Account -> Html Msg accountLinkSmall : Bool -> Account -> Html Msg
@ -86,10 +100,33 @@ accountLinkLarge external account =
else else
account.display_name account.display_name
, br [] [] , br [] []
, span [ class "acct" ] [ text <| "@" ++ account.acct ] , accountAcctView True account
] ]
instanceIconsView : String -> Html Msg
instanceIconsView url =
let
instUrl = String.join "/" ( List.take 3 ( String.split "/" url ) )
instIcon = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.png" ), alt "" ] []
instIcon2 = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.ico" ), alt "" ] []
in
span [] [ instIcon, instIcon2 ]
accountAcctView : Bool -> Account -> Html Msg
accountAcctView showIcons account =
let
acctText = text <| " @" ++ account.acct
icons =
if showIcons then
instanceIconsView <| account.url
else
text ""
in
span [ class "acct" ] [ acctText, icons ]
accountAvatarLink : Bool -> Account -> Html Msg accountAvatarLink : Bool -> Account -> Html Msg
accountAvatarLink external account = accountAvatarLink external account =
let let

View File

@ -260,17 +260,6 @@ statusEntryView context className currentUser status =
] ]
statusAcctView : Account -> Html Msg
statusAcctView account =
let
acctText = text <| " @" ++ account.acct
instUrl = String.join "/" ( List.take 3 ( String.split "/" account.url ) )
instIcon = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.png" ), alt "" ] []
instIcon2 = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.ico" ), alt "" ] []
in
span [ class "acct" ] [ acctText, instIcon, instIcon2 ]
statusView : String -> Status -> Bool -> Html Msg statusView : String -> Status -> Bool -> Html Msg
statusView context ({ account, content, media_attachments, reblog, mentions, pinned } as status) clickOpen = statusView context ({ account, content, media_attachments, reblog, mentions, pinned } as status) clickOpen =
let let
@ -316,7 +305,7 @@ statusView context ({ account, content, media_attachments, reblog, mentions, pin
, div [ class "username" ] , div [ class "username" ]
[ a accountLinkAttributes [ a accountLinkAttributes
[ text (if account.display_name=="" then account.username else account.display_name) [ text (if account.display_name=="" then account.username else account.display_name)
, statusAcctView <| account , Common.accountAcctView True account
] ]
] ]
, Lazy.lazy2 statusContentView context status , Lazy.lazy2 statusContentView context status