Mark timelines as loading.
This commit is contained in:
parent
8344d63f47
commit
bda0a82f3f
|
@ -83,6 +83,7 @@ emptyTimeline id =
|
||||||
{ id = id
|
{ id = id
|
||||||
, entries = []
|
, entries = []
|
||||||
, links = Links Nothing Nothing
|
, links = Links Nothing Nothing
|
||||||
|
, loading = False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -482,6 +483,37 @@ updateViewer viewerMsg viewer =
|
||||||
(Just <| Viewer attachments attachment) ! []
|
(Just <| Viewer attachments attachment) ! []
|
||||||
|
|
||||||
|
|
||||||
|
markTimelineLoading : Bool -> String -> Model -> Model
|
||||||
|
markTimelineLoading loading id model =
|
||||||
|
let
|
||||||
|
mark timeline =
|
||||||
|
{ timeline | loading = loading }
|
||||||
|
in
|
||||||
|
case id of
|
||||||
|
"notifications" ->
|
||||||
|
{ model | notifications = mark model.notifications }
|
||||||
|
|
||||||
|
"home-timeline" ->
|
||||||
|
{ model | homeTimeline = mark model.homeTimeline }
|
||||||
|
|
||||||
|
"local-timeline" ->
|
||||||
|
{ model | localTimeline = mark model.localTimeline }
|
||||||
|
|
||||||
|
"global-timeline" ->
|
||||||
|
{ model | globalTimeline = mark model.globalTimeline }
|
||||||
|
|
||||||
|
"account-timeline" ->
|
||||||
|
case model.currentView of
|
||||||
|
AccountView account ->
|
||||||
|
{ model | accountTimeline = mark model.accountTimeline }
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
model
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
model
|
||||||
|
|
||||||
|
|
||||||
updateTimeline : Bool -> List a -> Links -> Timeline a -> Timeline a
|
updateTimeline : Bool -> List a -> Links -> Timeline a -> Timeline a
|
||||||
updateTimeline append entries links timeline =
|
updateTimeline append entries links timeline =
|
||||||
let
|
let
|
||||||
|
@ -491,7 +523,11 @@ updateTimeline append entries links timeline =
|
||||||
else
|
else
|
||||||
entries
|
entries
|
||||||
in
|
in
|
||||||
{ timeline | entries = newEntries, links = links }
|
{ timeline
|
||||||
|
| entries = newEntries
|
||||||
|
, links = links
|
||||||
|
, loading = False
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
prependToTimeline : a -> Timeline a -> Timeline a
|
prependToTimeline : a -> Timeline a -> Timeline a
|
||||||
|
@ -939,7 +975,8 @@ update msg model =
|
||||||
! [ Command.loadAccount model.client accountId ]
|
! [ Command.loadAccount model.client accountId ]
|
||||||
|
|
||||||
TimelineLoadNext id next ->
|
TimelineLoadNext id next ->
|
||||||
model ! [ Command.loadNextTimeline model.client model.currentView id next ]
|
markTimelineLoading True id model
|
||||||
|
! [ Command.loadNextTimeline model.client model.currentView id next ]
|
||||||
|
|
||||||
ViewAccountFollowers account ->
|
ViewAccountFollowers account ->
|
||||||
{ model | currentView = AccountFollowersView account model.accountFollowers }
|
{ model | currentView = AccountFollowersView account model.accountFollowers }
|
||||||
|
|
|
@ -155,6 +155,7 @@ type alias Timeline a =
|
||||||
{ id : String
|
{ id : String
|
||||||
, entries : List a
|
, entries : List a
|
||||||
, links : Links
|
, links : Links
|
||||||
|
, loading : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,17 +82,22 @@ justifiedButtonGroup cls buttons =
|
||||||
List.map (\b -> div [ class "btn-group" ] [ b ]) buttons
|
List.map (\b -> div [ class "btn-group" ] [ b ]) buttons
|
||||||
|
|
||||||
|
|
||||||
loadMoreBtn : { timeline | id : String, links : Links } -> Html Msg
|
loadMoreBtn : { timeline | id : String, links : Links, loading : Bool } -> Html Msg
|
||||||
loadMoreBtn timeline =
|
loadMoreBtn { id, links, loading } =
|
||||||
case timeline.links.next of
|
if loading then
|
||||||
Just next ->
|
-- TODO: proper spinner
|
||||||
li [ class "list-group-item load-more text-center" ]
|
li [ class "list-group-item load-more text-center" ]
|
||||||
[ a
|
[ text "Loading..." ]
|
||||||
[ href next
|
else
|
||||||
, onClickWithPreventAndStop <| TimelineLoadNext timeline.id next
|
case links.next of
|
||||||
|
Just next ->
|
||||||
|
li [ class "list-group-item load-more text-center" ]
|
||||||
|
[ a
|
||||||
|
[ href next
|
||||||
|
, onClickWithPreventAndStop <| TimelineLoadNext id next
|
||||||
|
]
|
||||||
|
[ text "Load more" ]
|
||||||
]
|
]
|
||||||
[ text "Load more" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
text ""
|
text ""
|
||||||
|
|
Loading…
Reference in New Issue