Update search functionality

APIv1 search is deprecated and doesn't work anymore.
This commit is contained in:
Ryan Fox 2021-01-12 00:12:13 +00:00
parent 0222df76c7
commit 0f7a4c6bcf
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
7 changed files with 71 additions and 17 deletions

View File

@ -116,6 +116,10 @@ li.load-more {
clear: both; clear: both;
} }
.list-group-item.status {
min-height: 70px;
}
.current-user { .current-user {
min-height: 55px; min-height: 55px;
} }

View File

@ -42,6 +42,10 @@ apiPrefix : String
apiPrefix = apiPrefix =
"/api/v1" "/api/v1"
api2Prefix : String
api2Prefix =
"/api/v2"
apps : String apps : String
apps = apps =
@ -105,7 +109,7 @@ userAccount =
search : String search : String
search = search =
apiPrefix ++ "/search" api2Prefix ++ "/search"
searchAccount : String searchAccount : String

View File

@ -15,6 +15,8 @@ module Mastodon.Decoder
, tagDecoder , tagDecoder
, reblogDecoder , reblogDecoder
, relationshipDecoder , relationshipDecoder
, hashtagHistoryDecoder
, hashtagDecoder
, searchResultsDecoder , searchResultsDecoder
, statusDecoder , statusDecoder
, webSocketEventDecoder , webSocketEventDecoder
@ -189,12 +191,28 @@ reblogDecoder =
Decode.map Reblog (Decode.lazy (\_ -> statusDecoder)) Decode.map Reblog (Decode.lazy (\_ -> statusDecoder))
hashtagHistoryDecoder : Decode.Decoder HashtagHistory
hashtagHistoryDecoder =
Pipe.decode HashtagHistory
|> Pipe.required "day" Decode.string
|> Pipe.required "uses" Decode.string
|> Pipe.required "accounts" Decode.string
hashtagDecoder : Decode.Decoder Hashtag
hashtagDecoder =
Pipe.decode Hashtag
|> Pipe.required "name" Decode.string
|> Pipe.required "url" Decode.string
|> Pipe.required "history" (Decode.list hashtagHistoryDecoder)
searchResultsDecoder : Decode.Decoder SearchResults searchResultsDecoder : Decode.Decoder SearchResults
searchResultsDecoder = searchResultsDecoder =
Pipe.decode SearchResults Pipe.decode SearchResults
|> Pipe.required "accounts" (Decode.list accountDecoder) |> Pipe.required "accounts" (Decode.list accountDecoder)
|> Pipe.required "statuses" (Decode.list statusDecoder) |> Pipe.required "statuses" (Decode.list statusDecoder)
|> Pipe.required "hashtags" (Decode.list Decode.string) |> Pipe.required "hashtags" (Decode.list hashtagDecoder)
idDecoder : Decode.Decoder String idDecoder : Decode.Decoder String

View File

@ -11,6 +11,8 @@ module Mastodon.Model
, Emoji , Emoji
, Error(..) , Error(..)
, Field , Field
, HashtagHistory
, Hashtag
, Mention , Mention
, Notification , Notification
, NotificationAggregate , NotificationAggregate
@ -206,10 +208,24 @@ type alias Relationship =
} }
type alias HashtagHistory =
{ day : String
, uses : String
, accounts : String
}
type alias Hashtag =
{ name : String
, url : String
, history : List HashtagHistory
}
type alias SearchResults = type alias SearchResults =
{ accounts : List Account { accounts : List Account
, statuses : List Status , statuses : List Status
, hashtags : List String , hashtags : List Hashtag
} }

View File

@ -4,6 +4,7 @@ module View.Common
, accountAvatarLink , accountAvatarLink
, accountLink , accountLink
, accountLinkSmall , accountLinkSmall
, accountLinkLarge
, appLink , appLink
, closeablePanelheading , closeablePanelheading
, icon , icon
@ -67,6 +68,28 @@ accountLinkSmall external account =
] ]
accountLinkLarge : Bool -> Account -> Html Msg
accountLinkLarge external account =
let
accountHref =
if external then
target "_blank"
else
href <| "#account/" ++ account.id
in
a
[ href <| "#account/" ++ account.id
]
[ text <|
if account.display_name == "" then
account.username
else
account.display_name
, br [] []
, span [ class "acct" ] [ text <| "@" ++ account.acct ]
]
accountAvatarLink : Bool -> Account -> Html Msg accountAvatarLink : Bool -> Account -> Html Msg
accountAvatarLink external account = accountAvatarLink external account =
let let

View File

@ -112,18 +112,7 @@ notificationFollowView currentUser { accounts } =
div [ class "status follow-profile" ] div [ class "status follow-profile" ]
[ Common.accountAvatarLink False account [ Common.accountAvatarLink False account
, div [ class "username" ] , div [ class "username" ]
[ [ Common.accountLinkLarge False account
a
[ href <| "#account/" ++ account.id
]
[ text <|
if account.display_name == "" then
account.username
else
account.display_name
, br [] []
, span [ class "acct" ] [ text <| "@" ++ account.acct ]
]
, span [ class "btn-sm follow-profile-date" ] , span [ class "btn-sm follow-profile-date" ]
[ Common.icon "time", text <| Common.formatDate created_at ] [ Common.icon "time", text <| Common.formatDate created_at ]
] ]

View File

@ -16,7 +16,7 @@ accountListView accounts =
profileView account = profileView account =
li [ class "list-group-item status follow-profile" ] li [ class "list-group-item status follow-profile" ]
[ Common.accountAvatarLink False account [ Common.accountAvatarLink False account
, div [ class "username" ] [ Common.accountLink False account ] , div [ class "username" ] [ Common.accountLinkLarge False account ]
, formatContent account.note [] , formatContent account.note []
|> div |> div
[ class "status-text" [ class "status-text"
@ -47,7 +47,7 @@ searchResultsView results =
hashtags -> hashtags ->
hashtags hashtags
|> List.map (\h -> a [ class "list-group-item", href <| "#hashtag/" ++ h ] [ text <| "#" ++ h ]) |> List.map (\h -> a [ class "list-group-item", href <| "#hashtag/" ++ h.name ] [ text <| "#" ++ h.name ])
|> div [ class "list-group" ] |> div [ class "list-group" ]
in in
div [ class "timeline" ] div [ class "timeline" ]