HomeTimeline: pull to refresh
This commit is contained in:
parent
3ad3b5c84a
commit
9ce3aa8d1b
|
@ -9,6 +9,7 @@ import { throttle } from 'lodash';
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import LoadingIndicator from './loading_indicator';
|
import LoadingIndicator from './loading_indicator';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
|
import PullToRefresh from 'soapbox/components/pull_to_refresh';
|
||||||
|
|
||||||
const MOUSE_IDLE_DELAY = 300;
|
const MOUSE_IDLE_DELAY = 300;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ class ScrollableList extends PureComponent {
|
||||||
placeholderComponent: PropTypes.func,
|
placeholderComponent: PropTypes.func,
|
||||||
placeholderCount: PropTypes.number,
|
placeholderCount: PropTypes.number,
|
||||||
autoload: PropTypes.bool,
|
autoload: PropTypes.bool,
|
||||||
|
onRefresh: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -274,12 +276,12 @@ class ScrollableList extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFeed = () => {
|
renderFeed = () => {
|
||||||
const { children, scrollKey, isLoading, hasMore, prepend, onLoadMore, placeholderComponent: Placeholder } = this.props;
|
const { children, scrollKey, isLoading, hasMore, prepend, onLoadMore, onRefresh, placeholderComponent: Placeholder } = this.props;
|
||||||
const childrenCount = React.Children.count(children);
|
const childrenCount = React.Children.count(children);
|
||||||
const trackScroll = true; //placeholder
|
const trackScroll = true; //placeholder
|
||||||
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
||||||
|
|
||||||
return (
|
const feed = (
|
||||||
<div className='slist' ref={this.setRef} onMouseMove={this.handleMouseMove}>
|
<div className='slist' ref={this.setRef} onMouseMove={this.handleMouseMove}>
|
||||||
<div role='feed' className='item-list'>
|
<div role='feed' className='item-list'>
|
||||||
{prepend}
|
{prepend}
|
||||||
|
@ -313,6 +315,16 @@ class ScrollableList extends PureComponent {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (onRefresh) {
|
||||||
|
return (
|
||||||
|
<PullToRefresh onRefresh={onRefresh}>
|
||||||
|
{feed}
|
||||||
|
</PullToRefresh>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return feed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -93,6 +93,11 @@ class HomeTimeline extends React.PureComponent {
|
||||||
this.setState({ done: true });
|
this.setState({ done: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleRefresh = () => {
|
||||||
|
const { dispatch } = this.props;
|
||||||
|
return dispatch(expandHomeTimeline());
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { intl, siteTitle, isLoading, isEmpty, features } = this.props;
|
const { intl, siteTitle, isLoading, isEmpty, features } = this.props;
|
||||||
const { done } = this.state;
|
const { done } = this.state;
|
||||||
|
@ -108,6 +113,7 @@ class HomeTimeline extends React.PureComponent {
|
||||||
<StatusListContainer
|
<StatusListContainer
|
||||||
scrollKey='home_timeline'
|
scrollKey='home_timeline'
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
|
onRefresh={this.handleRefresh}
|
||||||
timelineId='home'
|
timelineId='home'
|
||||||
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} to get started and meet other users.' values={{ public: <Link to='/timeline/local'><FormattedMessage id='empty_column.home.local_tab' defaultMessage='the {site_title} tab' values={{ site_title: siteTitle }} /></Link> }} />}
|
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} to get started and meet other users.' values={{ public: <Link to='/timeline/local'><FormattedMessage id='empty_column.home.local_tab' defaultMessage='the {site_title} tab' values={{ site_title: siteTitle }} /></Link> }} />}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue