Allow clients to fetch statuses made while they were offline (#6876)

This commit is contained in:
Akihiko Odaki
2018-03-24 23:25:15 +09:00
committed by Eugen Rochko
parent 59657e24b9
commit 9a1a55ce52
22 changed files with 191 additions and 259 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { expandHomeTimeline, refreshHomeTimeline } from '../../actions/timelines';
import { expandHomeTimeline } from '../../actions/timelines';
import PropTypes from 'prop-types';
import StatusListContainer from '../ui/containers/status_list_container';
import Column from '../../components/column';
@ -16,7 +16,7 @@ const messages = defineMessages({
const mapStateToProps = state => ({
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
isPartial: state.getIn(['timelines', 'home', 'isPartial'], false),
isPartial: state.getIn(['timelines', 'home', 'items', 0], null) === null,
});
@connect(mapStateToProps)
@ -55,8 +55,8 @@ export default class HomeTimeline extends React.PureComponent {
this.column = c;
}
handleLoadMore = () => {
this.props.dispatch(expandHomeTimeline());
handleLoadMore = maxId => {
this.props.dispatch(expandHomeTimeline({ maxId }));
}
componentDidMount () {
@ -78,7 +78,7 @@ export default class HomeTimeline extends React.PureComponent {
return;
} else if (!wasPartial && isPartial) {
this.polling = setInterval(() => {
dispatch(refreshHomeTimeline());
dispatch(expandHomeTimeline());
}, 3000);
} else if (wasPartial && !isPartial) {
this._stopPolling();
@ -114,7 +114,7 @@ export default class HomeTimeline extends React.PureComponent {
<StatusListContainer
trackScroll={!pinned}
scrollKey={`home_timeline-${columnId}`}
loadMore={this.handleLoadMore}
onLoadMore={this.handleLoadMore}
timelineId='home'
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} or use search to get started and meet other users.' values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />}
/>