parent
f90f41571b
commit
75de9b8c08
@ -165,27 +165,27 @@ loadAccount client accountId =
|
|||||||
Cmd.none
|
Cmd.none
|
||||||
|
|
||||||
|
|
||||||
loadAccountFollowers : Maybe Client -> Int -> Cmd Msg
|
loadAccountFollowers : Maybe Client -> Int -> Maybe String -> Cmd Msg
|
||||||
loadAccountFollowers client accountId =
|
loadAccountFollowers client accountId url =
|
||||||
case client of
|
case client of
|
||||||
Just client ->
|
Just client ->
|
||||||
HttpBuilder.get (ApiUrl.followers accountId)
|
HttpBuilder.get (Maybe.withDefault (ApiUrl.followers accountId) url)
|
||||||
|> withClient client
|
|> withClient client
|
||||||
|> withBodyDecoder (Decode.list accountDecoder)
|
|> withBodyDecoder (Decode.list accountDecoder)
|
||||||
|> send (MastodonEvent << AccountFollowers)
|
|> send (MastodonEvent << AccountFollowers (url /= Nothing))
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
|
|
||||||
|
|
||||||
loadAccountFollowing : Maybe Client -> Int -> Cmd Msg
|
loadAccountFollowing : Maybe Client -> Int -> Maybe String -> Cmd Msg
|
||||||
loadAccountFollowing client accountId =
|
loadAccountFollowing client accountId url =
|
||||||
case client of
|
case client of
|
||||||
Just client ->
|
Just client ->
|
||||||
HttpBuilder.get (ApiUrl.following accountId)
|
HttpBuilder.get (Maybe.withDefault (ApiUrl.following accountId) url)
|
||||||
|> withClient client
|
|> withClient client
|
||||||
|> withBodyDecoder (Decode.list accountDecoder)
|
|> withBodyDecoder (Decode.list accountDecoder)
|
||||||
|> send (MastodonEvent << AccountFollowing)
|
|> send (MastodonEvent << AccountFollowing (url /= Nothing))
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
@ -345,6 +345,22 @@ loadNextTimeline client currentView id next =
|
|||||||
_ ->
|
_ ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
|
|
||||||
|
"account-followers" ->
|
||||||
|
case currentView of
|
||||||
|
AccountFollowersView account timeline ->
|
||||||
|
loadAccountFollowers client account.id (Just next)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Cmd.none
|
||||||
|
|
||||||
|
"account-following" ->
|
||||||
|
case currentView of
|
||||||
|
AccountFollowingView account timeline ->
|
||||||
|
loadAccountFollowing client account.id (Just next)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Cmd.none
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Cmd.none
|
Cmd.none
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ init { registration, client } location =
|
|||||||
, localTimeline = Update.Timeline.empty "local-timeline"
|
, localTimeline = Update.Timeline.empty "local-timeline"
|
||||||
, globalTimeline = Update.Timeline.empty "global-timeline"
|
, globalTimeline = Update.Timeline.empty "global-timeline"
|
||||||
, accountTimeline = Update.Timeline.empty "account-timeline"
|
, accountTimeline = Update.Timeline.empty "account-timeline"
|
||||||
, accountFollowers = []
|
, accountFollowers = Update.Timeline.empty "account-followers"
|
||||||
, accountFollowing = []
|
, accountFollowing = Update.Timeline.empty "account-following"
|
||||||
, accountRelationships = []
|
, accountRelationships = []
|
||||||
, accountRelationship = Nothing
|
, accountRelationship = Nothing
|
||||||
, notifications = Update.Timeline.empty "notifications"
|
, notifications = Update.Timeline.empty "notifications"
|
||||||
|
@ -39,8 +39,8 @@ type alias MastodonResult a =
|
|||||||
type MastodonMsg
|
type MastodonMsg
|
||||||
= AccessToken (MastodonResult AccessTokenResult)
|
= AccessToken (MastodonResult AccessTokenResult)
|
||||||
| AccountFollowed (MastodonResult Relationship)
|
| AccountFollowed (MastodonResult Relationship)
|
||||||
| AccountFollowers (MastodonResult (List Account))
|
| AccountFollowers Bool (MastodonResult (List Account))
|
||||||
| AccountFollowing (MastodonResult (List Account))
|
| AccountFollowing Bool (MastodonResult (List Account))
|
||||||
| AccountReceived (MastodonResult Account)
|
| AccountReceived (MastodonResult Account)
|
||||||
| AccountRelationship (MastodonResult (List Relationship))
|
| AccountRelationship (MastodonResult (List Relationship))
|
||||||
| AccountRelationships (MastodonResult (List Relationship))
|
| AccountRelationships (MastodonResult (List Relationship))
|
||||||
@ -102,8 +102,8 @@ type Msg
|
|||||||
|
|
||||||
type CurrentView
|
type CurrentView
|
||||||
= -- Basically, what we should be displaying in the fourth column
|
= -- Basically, what we should be displaying in the fourth column
|
||||||
AccountFollowersView Account (List Account)
|
AccountFollowersView Account (Timeline Account)
|
||||||
| AccountFollowingView Account (List Account)
|
| AccountFollowingView Account (Timeline Account)
|
||||||
| AccountView Account
|
| AccountView Account
|
||||||
| GlobalTimelineView
|
| GlobalTimelineView
|
||||||
| LocalTimelineView
|
| LocalTimelineView
|
||||||
@ -177,8 +177,8 @@ type alias Model =
|
|||||||
, localTimeline : Timeline Status
|
, localTimeline : Timeline Status
|
||||||
, globalTimeline : Timeline Status
|
, globalTimeline : Timeline Status
|
||||||
, accountTimeline : Timeline Status
|
, accountTimeline : Timeline Status
|
||||||
, accountFollowers : List Account
|
, accountFollowers : Timeline Account
|
||||||
, accountFollowing : List Account
|
, accountFollowing : Timeline Account
|
||||||
, accountRelationships : List Relationship
|
, accountRelationships : List Relationship
|
||||||
, accountRelationship : Maybe Relationship
|
, accountRelationship : Maybe Relationship
|
||||||
, notifications : Timeline NotificationAggregate
|
, notifications : Timeline NotificationAggregate
|
||||||
|
@ -118,8 +118,8 @@ update msg model =
|
|||||||
LoadAccount accountId ->
|
LoadAccount accountId ->
|
||||||
{ model
|
{ model
|
||||||
| accountTimeline = Update.Timeline.empty "account-timeline"
|
| accountTimeline = Update.Timeline.empty "account-timeline"
|
||||||
, accountFollowers = []
|
, accountFollowers = Update.Timeline.empty "account-followers"
|
||||||
, accountFollowing = []
|
, accountFollowing = Update.Timeline.empty "account-following"
|
||||||
, accountRelationships = []
|
, accountRelationships = []
|
||||||
, accountRelationship = Nothing
|
, accountRelationship = Nothing
|
||||||
}
|
}
|
||||||
@ -130,12 +130,18 @@ update msg model =
|
|||||||
! [ Command.loadNextTimeline model.client model.currentView id next ]
|
! [ Command.loadNextTimeline model.client model.currentView id next ]
|
||||||
|
|
||||||
ViewAccountFollowers account ->
|
ViewAccountFollowers account ->
|
||||||
{ model | currentView = AccountFollowersView account model.accountFollowers }
|
{ model
|
||||||
! [ Command.loadAccountFollowers model.client account.id ]
|
| currentView = AccountFollowersView account model.accountFollowers
|
||||||
|
, accountRelationships = []
|
||||||
|
}
|
||||||
|
! [ Command.loadAccountFollowers model.client account.id Nothing ]
|
||||||
|
|
||||||
ViewAccountFollowing account ->
|
ViewAccountFollowing account ->
|
||||||
{ model | currentView = AccountFollowingView account model.accountFollowing }
|
{ model
|
||||||
! [ Command.loadAccountFollowing model.client account.id ]
|
| currentView = AccountFollowingView account model.accountFollowing
|
||||||
|
, accountRelationships = []
|
||||||
|
}
|
||||||
|
! [ Command.loadAccountFollowing model.client account.id Nothing ]
|
||||||
|
|
||||||
ViewAccountStatuses account ->
|
ViewAccountStatuses account ->
|
||||||
{ model | currentView = AccountView account } ! []
|
{ model | currentView = AccountView account } ! []
|
||||||
@ -151,8 +157,8 @@ update msg model =
|
|||||||
{ model
|
{ model
|
||||||
| currentView = Update.Timeline.preferred model
|
| currentView = Update.Timeline.preferred model
|
||||||
, accountTimeline = Update.Timeline.empty "account-timeline"
|
, accountTimeline = Update.Timeline.empty "account-timeline"
|
||||||
, accountFollowing = []
|
, accountFollowing = Update.Timeline.empty "account-following"
|
||||||
, accountFollowers = []
|
, accountFollowers = Update.Timeline.empty "account-followers"
|
||||||
}
|
}
|
||||||
! []
|
! []
|
||||||
|
|
||||||
|
@ -178,7 +178,10 @@ update msg model =
|
|||||||
AccountReceived result ->
|
AccountReceived result ->
|
||||||
case result of
|
case result of
|
||||||
Ok { decoded } ->
|
Ok { decoded } ->
|
||||||
{ model | currentView = AccountView decoded }
|
{ model
|
||||||
|
| currentView = AccountView decoded
|
||||||
|
, accountRelationships = []
|
||||||
|
}
|
||||||
! [ Command.loadAccountTimeline model.client decoded.id model.accountTimeline.links.next ]
|
! [ Command.loadAccountTimeline model.client decoded.id model.accountTimeline.links.next ]
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
@ -196,21 +199,19 @@ update msg model =
|
|||||||
Err error ->
|
Err error ->
|
||||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||||
|
|
||||||
AccountFollowers result ->
|
AccountFollowers append result ->
|
||||||
case result of
|
case result of
|
||||||
Ok { decoded } ->
|
Ok { decoded, links } ->
|
||||||
-- TODO: store next link
|
{ model | accountFollowers = Update.Timeline.update append decoded links model.accountFollowers }
|
||||||
{ model | accountFollowers = decoded }
|
|
||||||
! [ Command.loadRelationships model.client <| List.map .id decoded ]
|
! [ Command.loadRelationships model.client <| List.map .id decoded ]
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||||
|
|
||||||
AccountFollowing result ->
|
AccountFollowing append result ->
|
||||||
case result of
|
case result of
|
||||||
Ok { decoded } ->
|
Ok { decoded, links } ->
|
||||||
-- TODO: store next link
|
{ model | accountFollowing = Update.Timeline.update append decoded links model.accountFollowing }
|
||||||
{ model | accountFollowing = decoded }
|
|
||||||
! [ Command.loadRelationships model.client <| List.map .id decoded ]
|
! [ Command.loadRelationships model.client <| List.map .id decoded ]
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
@ -232,8 +233,10 @@ update msg model =
|
|||||||
AccountRelationships result ->
|
AccountRelationships result ->
|
||||||
case result of
|
case result of
|
||||||
Ok { decoded } ->
|
Ok { decoded } ->
|
||||||
-- TODO: store next link
|
{ model
|
||||||
{ model | accountRelationships = decoded } ! []
|
| accountRelationships = List.concat [ model.accountRelationships, decoded ]
|
||||||
|
}
|
||||||
|
! []
|
||||||
|
|
||||||
Err error ->
|
Err error ->
|
||||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||||
|
@ -100,12 +100,12 @@ followView currentUser relationship account =
|
|||||||
|
|
||||||
accountFollowView :
|
accountFollowView :
|
||||||
CurrentUser
|
CurrentUser
|
||||||
-> List Account
|
-> Timeline Account
|
||||||
-> List Relationship
|
-> List Relationship
|
||||||
-> CurrentUserRelation
|
-> CurrentUserRelation
|
||||||
-> Account
|
-> Account
|
||||||
-> Html Msg
|
-> Html Msg
|
||||||
accountFollowView currentUser accounts relationships relationship account =
|
accountFollowView currentUser timeline relationships relationship account =
|
||||||
let
|
let
|
||||||
keyedEntry account =
|
keyedEntry account =
|
||||||
( toString account.id
|
( toString account.id
|
||||||
@ -116,10 +116,13 @@ accountFollowView currentUser accounts relationships relationship account =
|
|||||||
account
|
account
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entries =
|
||||||
|
List.map keyedEntry timeline.entries
|
||||||
in
|
in
|
||||||
accountView currentUser account relationship <|
|
accountView currentUser account relationship <|
|
||||||
Keyed.ul [ class "list-group" ] <|
|
Keyed.ul [ class "list-group" ] <|
|
||||||
List.map keyedEntry accounts
|
(entries ++ [ ( "load-more", Common.loadMoreBtn timeline ) ])
|
||||||
|
|
||||||
|
|
||||||
accountTimelineView : CurrentUser -> Timeline Status -> CurrentUserRelation -> Account -> Html Msg
|
accountTimelineView : CurrentUser -> Timeline Status -> CurrentUserRelation -> Account -> Html Msg
|
||||||
|
Loading…
Reference in New Issue
Block a user