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;
}
.list-group-item.status {
min-height: 70px;
}
.current-user {
min-height: 55px;
}

View File

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

View File

@ -15,6 +15,8 @@ module Mastodon.Decoder
, tagDecoder
, reblogDecoder
, relationshipDecoder
, hashtagHistoryDecoder
, hashtagDecoder
, searchResultsDecoder
, statusDecoder
, webSocketEventDecoder
@ -189,12 +191,28 @@ reblogDecoder =
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 =
Pipe.decode SearchResults
|> Pipe.required "accounts" (Decode.list accountDecoder)
|> Pipe.required "statuses" (Decode.list statusDecoder)
|> Pipe.required "hashtags" (Decode.list Decode.string)
|> Pipe.required "hashtags" (Decode.list hashtagDecoder)
idDecoder : Decode.Decoder String

View File

@ -11,6 +11,8 @@ module Mastodon.Model
, Emoji
, Error(..)
, Field
, HashtagHistory
, Hashtag
, Mention
, Notification
, 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 =
{ accounts : List Account
, statuses : List Status
, hashtags : List String
, hashtags : List Hashtag
}

View File

@ -4,6 +4,7 @@ module View.Common
, accountAvatarLink
, accountLink
, accountLinkSmall
, accountLinkLarge
, appLink
, closeablePanelheading
, 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 external account =
let

View File

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

View File

@ -16,7 +16,7 @@ accountListView accounts =
profileView account =
li [ class "list-group-item status follow-profile" ]
[ Common.accountAvatarLink False account
, div [ class "username" ] [ Common.accountLink False account ]
, div [ class "username" ] [ Common.accountLinkLarge False account ]
, formatContent account.note []
|> div
[ class "status-text"
@ -47,7 +47,7 @@ searchResultsView results =
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" ]
in
div [ class "timeline" ]