diff --git a/app/assets/javascripts/components/actions/timelines.jsx b/app/assets/javascripts/components/actions/timelines.jsx index d6de32ea14a..8a05c37fdc4 100644 --- a/app/assets/javascripts/components/actions/timelines.jsx +++ b/app/assets/javascripts/components/actions/timelines.jsx @@ -60,3 +60,40 @@ export function refreshTimelineFail(timeline, error) { error: error }; }; + +export function expandTimeline(timeline) { + return (dispatch, getState) => { + const lastId = getState().getIn(['timelines', timeline]).last(); + + dispatch(expandTimelineRequest(timeline)); + + api(getState).get(`/api/statuses/${timeline}?max_id=${lastId}`).then(response => { + dispatch(expandTimelineSuccess(timeline, response.data)); + }).catch(error => { + dispatch(expandTimelineFail(timeline, error)); + }); + }; +}; + +export function expandTimelineRequest(timeline) { + return { + type: TIMELINE_EXPAND_REQUEST, + timeline: timeline + }; +}; + +export function expandTimelineSuccess(timeline, statuses) { + return { + type: TIMELINE_EXPAND_SUCCESS, + timeline: timeline, + statuses: statuses + }; +}; + +export function expandTimelineFail(timeline, error) { + return { + type: TIMELINE_EXPAND_FAIL, + timeline: timeline, + error: error + }; +}; diff --git a/app/assets/javascripts/components/components/status_list.jsx b/app/assets/javascripts/components/components/status_list.jsx index 7fa81e5127b..381653d5d51 100644 --- a/app/assets/javascripts/components/components/status_list.jsx +++ b/app/assets/javascripts/components/components/status_list.jsx @@ -8,14 +8,23 @@ const StatusList = React.createClass({ statuses: ImmutablePropTypes.list.isRequired, onReply: React.PropTypes.func, onReblog: React.PropTypes.func, - onFavourite: React.PropTypes.func + onFavourite: React.PropTypes.func, + onScrollToBottom: React.PropTypes.func }, mixins: [PureRenderMixin], + handleScroll (e) { + const { scrollTop, scrollHeight, clientHeight } = e.target; + + if (scrollTop === scrollHeight - clientHeight) { + this.props.onScrollToBottom(); + } + }, + render () { return ( -