parent
e77dca0692
commit
75aa841ceb
|
@ -4,6 +4,7 @@ module Mastodon.ApiUrl
|
||||||
, oauthAuthorize
|
, oauthAuthorize
|
||||||
, oauthToken
|
, oauthToken
|
||||||
, account
|
, account
|
||||||
|
, accountTimeline
|
||||||
, homeTimeline
|
, homeTimeline
|
||||||
, publicTimeline
|
, publicTimeline
|
||||||
, notifications
|
, notifications
|
||||||
|
@ -65,6 +66,11 @@ publicTimeline local =
|
||||||
"/api/v1/timelines/public" ++ isLocal
|
"/api/v1/timelines/public" ++ isLocal
|
||||||
|
|
||||||
|
|
||||||
|
accountTimeline : Int -> String
|
||||||
|
accountTimeline id =
|
||||||
|
(account id) ++ "/statuses"
|
||||||
|
|
||||||
|
|
||||||
notifications : String
|
notifications : String
|
||||||
notifications =
|
notifications =
|
||||||
"/api/v1/notifications"
|
"/api/v1/notifications"
|
||||||
|
|
|
@ -10,6 +10,7 @@ module Mastodon.Http
|
||||||
, getAuthorizationUrl
|
, getAuthorizationUrl
|
||||||
, getAccessToken
|
, getAccessToken
|
||||||
, fetchAccount
|
, fetchAccount
|
||||||
|
, fetchAccountTimeline
|
||||||
, fetchLocalTimeline
|
, fetchLocalTimeline
|
||||||
, fetchNotifications
|
, fetchNotifications
|
||||||
, fetchGlobalTimeline
|
, fetchGlobalTimeline
|
||||||
|
@ -21,6 +22,7 @@ module Mastodon.Http
|
||||||
import Http
|
import Http
|
||||||
import HttpBuilder
|
import HttpBuilder
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
|
import Task
|
||||||
import Mastodon.ApiUrl as ApiUrl
|
import Mastodon.ApiUrl as ApiUrl
|
||||||
import Mastodon.Decoder exposing (..)
|
import Mastodon.Decoder exposing (..)
|
||||||
import Mastodon.Encoder exposing (..)
|
import Mastodon.Encoder exposing (..)
|
||||||
|
@ -121,6 +123,11 @@ fetchGlobalTimeline client =
|
||||||
fetch client (ApiUrl.publicTimeline (Nothing)) <| Decode.list statusDecoder
|
fetch client (ApiUrl.publicTimeline (Nothing)) <| Decode.list statusDecoder
|
||||||
|
|
||||||
|
|
||||||
|
fetchAccountTimeline : Client -> Int -> Request (List Status)
|
||||||
|
fetchAccountTimeline client id =
|
||||||
|
fetch client (ApiUrl.accountTimeline id) <| Decode.list statusDecoder
|
||||||
|
|
||||||
|
|
||||||
fetchNotifications : Client -> Request (List Notification)
|
fetchNotifications : Client -> Request (List Notification)
|
||||||
fetchNotifications client =
|
fetchNotifications client =
|
||||||
fetch client (ApiUrl.notifications) <| Decode.list notificationDecoder
|
fetch client (ApiUrl.notifications) <| Decode.list notificationDecoder
|
||||||
|
|
|
@ -47,7 +47,8 @@ type MastodonMsg
|
||||||
| Reblogged (Result Mastodon.Model.Error Mastodon.Model.Status)
|
| Reblogged (Result Mastodon.Model.Error Mastodon.Model.Status)
|
||||||
| StatusPosted (Result Mastodon.Model.Error Mastodon.Model.Status)
|
| StatusPosted (Result Mastodon.Model.Error Mastodon.Model.Status)
|
||||||
| Unreblogged (Result Mastodon.Model.Error Mastodon.Model.Status)
|
| Unreblogged (Result Mastodon.Model.Error Mastodon.Model.Status)
|
||||||
| UserAccount (Result Mastodon.Model.Error Mastodon.Model.Account)
|
| Account (Result Mastodon.Model.Error Mastodon.Model.Account)
|
||||||
|
| AccountTimeline (Result Mastodon.Model.Error (List Mastodon.Model.Status))
|
||||||
| UserTimeline (Result Mastodon.Model.Error (List Mastodon.Model.Status))
|
| UserTimeline (Result Mastodon.Model.Error (List Mastodon.Model.Status))
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ type Msg
|
||||||
| ClearOpenedAccount
|
| ClearOpenedAccount
|
||||||
| CloseThread
|
| CloseThread
|
||||||
| DraftEvent DraftMsg
|
| DraftEvent DraftMsg
|
||||||
| LoadUserAccount Int
|
| LoadAccount Int
|
||||||
| MastodonEvent MastodonMsg
|
| MastodonEvent MastodonMsg
|
||||||
| NoOp
|
| NoOp
|
||||||
| OpenThread Mastodon.Model.Status
|
| OpenThread Mastodon.Model.Status
|
||||||
|
@ -114,6 +115,7 @@ type alias Model =
|
||||||
, userTimeline : List Mastodon.Model.Status
|
, userTimeline : List Mastodon.Model.Status
|
||||||
, localTimeline : List Mastodon.Model.Status
|
, localTimeline : List Mastodon.Model.Status
|
||||||
, globalTimeline : List Mastodon.Model.Status
|
, globalTimeline : List Mastodon.Model.Status
|
||||||
|
, accountTimeline : List Mastodon.Model.Status
|
||||||
, notifications : List Mastodon.Model.NotificationAggregate
|
, notifications : List Mastodon.Model.NotificationAggregate
|
||||||
, draft : Draft
|
, draft : Draft
|
||||||
, errors : List String
|
, errors : List String
|
||||||
|
@ -156,6 +158,7 @@ init flags location =
|
||||||
, userTimeline = []
|
, userTimeline = []
|
||||||
, localTimeline = []
|
, localTimeline = []
|
||||||
, globalTimeline = []
|
, globalTimeline = []
|
||||||
|
, accountTimeline = []
|
||||||
, notifications = []
|
, notifications = []
|
||||||
, draft = defaultDraft
|
, draft = defaultDraft
|
||||||
, errors = []
|
, errors = []
|
||||||
|
@ -502,7 +505,7 @@ processMastodonEvent msg model =
|
||||||
Err error ->
|
Err error ->
|
||||||
{ model | errors = (errorText error) :: model.errors } ! []
|
{ model | errors = (errorText error) :: model.errors } ! []
|
||||||
|
|
||||||
UserAccount result ->
|
Account result ->
|
||||||
case result of
|
case result of
|
||||||
Ok account ->
|
Ok account ->
|
||||||
{ model | currentView = AccountView account } ! []
|
{ model | currentView = AccountView account } ! []
|
||||||
|
@ -514,6 +517,14 @@ processMastodonEvent msg model =
|
||||||
}
|
}
|
||||||
! []
|
! []
|
||||||
|
|
||||||
|
AccountTimeline result ->
|
||||||
|
case result of
|
||||||
|
Ok statuses ->
|
||||||
|
{ model | accountTimeline = statuses } ! []
|
||||||
|
|
||||||
|
Err error ->
|
||||||
|
{ model | errors = (errorText error) :: model.errors } ! []
|
||||||
|
|
||||||
UserTimeline result ->
|
UserTimeline result ->
|
||||||
case result of
|
case result of
|
||||||
Ok userTimeline ->
|
Ok userTimeline ->
|
||||||
|
@ -723,17 +734,19 @@ update msg model =
|
||||||
Nothing ->
|
Nothing ->
|
||||||
[]
|
[]
|
||||||
|
|
||||||
LoadUserAccount accountId ->
|
LoadAccount accountId ->
|
||||||
{-
|
{-
|
||||||
@TODO
|
@TODO
|
||||||
When requesting a user profile, we should load a new "page"
|
When requesting a user profile, we should load a new "page"
|
||||||
so that the URL in the browser matches the user displayed
|
so that the URL in the browser matches the user displayed
|
||||||
-}
|
-}
|
||||||
model
|
{ model | currentView = preferredTimeline model }
|
||||||
! case model.client of
|
! case model.client of
|
||||||
Just client ->
|
Just client ->
|
||||||
[ Mastodon.Http.fetchAccount client accountId
|
[ Mastodon.Http.fetchAccount client accountId
|
||||||
|> Mastodon.Http.send (MastodonEvent << UserAccount)
|
|> Mastodon.Http.send (MastodonEvent << Account)
|
||||||
|
, Mastodon.Http.fetchAccountTimeline client accountId
|
||||||
|
|> Mastodon.Http.send (MastodonEvent << AccountTimeline)
|
||||||
]
|
]
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
|
|
@ -70,7 +70,7 @@ accountLink : Mastodon.Model.Account -> Html Msg
|
||||||
accountLink account =
|
accountLink account =
|
||||||
a
|
a
|
||||||
[ href account.url
|
[ href account.url
|
||||||
, ViewHelper.onClickWithPreventAndStop (LoadUserAccount account.id)
|
, ViewHelper.onClickWithPreventAndStop (LoadAccount account.id)
|
||||||
]
|
]
|
||||||
[ text <| "@" ++ account.username ]
|
[ text <| "@" ++ account.username ]
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ accountAvatarLink : Mastodon.Model.Account -> Html Msg
|
||||||
accountAvatarLink account =
|
accountAvatarLink account =
|
||||||
a
|
a
|
||||||
[ href account.url
|
[ href account.url
|
||||||
, ViewHelper.onClickWithPreventAndStop (LoadUserAccount account.id)
|
, ViewHelper.onClickWithPreventAndStop (LoadAccount account.id)
|
||||||
, title <| "@" ++ account.username
|
, title <| "@" ++ account.username
|
||||||
]
|
]
|
||||||
[ img [ class "avatar", src account.avatar ] [] ]
|
[ img [ class "avatar", src account.avatar ] [] ]
|
||||||
|
@ -174,7 +174,7 @@ statusView context ({ account, content, media_attachments, reblog, mentions } as
|
||||||
-- When clicking on a status, we should not let the browser
|
-- When clicking on a status, we should not let the browser
|
||||||
-- redirect to a new page. That's why we're preventing the default
|
-- redirect to a new page. That's why we're preventing the default
|
||||||
-- behavior here
|
-- behavior here
|
||||||
, ViewHelper.onClickWithPreventAndStop (LoadUserAccount account.id)
|
, ViewHelper.onClickWithPreventAndStop (LoadAccount account.id)
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
case reblog of
|
case reblog of
|
||||||
|
@ -611,7 +611,7 @@ homepageView model =
|
||||||
|
|
||||||
Model.AccountView account ->
|
Model.AccountView account ->
|
||||||
-- Todo: Load the user timeline
|
-- Todo: Load the user timeline
|
||||||
accountTimelineView account [] "Account" "user"
|
accountTimelineView account model.accountTimeline "Account" "user"
|
||||||
|
|
||||||
Model.ThreadView thread ->
|
Model.ThreadView thread ->
|
||||||
threadView thread
|
threadView thread
|
||||||
|
|
|
@ -13,7 +13,7 @@ import HtmlParser
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import String.Extra exposing (replace)
|
import String.Extra exposing (replace)
|
||||||
import Mastodon.Model
|
import Mastodon.Model
|
||||||
import Model exposing (Msg(LoadUserAccount))
|
import Model exposing (Msg(LoadAccount))
|
||||||
|
|
||||||
|
|
||||||
-- Custom Events
|
-- Custom Events
|
||||||
|
@ -58,7 +58,7 @@ createLinkNode attrs children mentions =
|
||||||
Just mention ->
|
Just mention ->
|
||||||
Html.node "a"
|
Html.node "a"
|
||||||
((List.map toAttribute attrs)
|
((List.map toAttribute attrs)
|
||||||
++ [ onClickWithPreventAndStop (LoadUserAccount mention.id) ]
|
++ [ onClickWithPreventAndStop (LoadAccount mention.id) ]
|
||||||
)
|
)
|
||||||
(toVirtualDom mentions children)
|
(toVirtualDom mentions children)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user