mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-15 14:48:40 +00:00
[Glitch] Replace onScrollToBottom with onLoadMore
Port b0664a5e6c
to glitch-soc
This commit is contained in:
parent
a81ed7b205
commit
8b98afa781
|
@ -17,7 +17,7 @@ export default class ScrollableList extends PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
scrollKey: PropTypes.string.isRequired,
|
scrollKey: PropTypes.string.isRequired,
|
||||||
onScrollToBottom: PropTypes.func,
|
onLoadMore: PropTypes.func.isRequired,
|
||||||
onScrollToTop: PropTypes.func,
|
onScrollToTop: PropTypes.func,
|
||||||
onScroll: PropTypes.func,
|
onScroll: PropTypes.func,
|
||||||
trackScroll: PropTypes.bool,
|
trackScroll: PropTypes.bool,
|
||||||
|
@ -44,9 +44,11 @@ export default class ScrollableList extends PureComponent {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = this.node;
|
const { scrollTop, scrollHeight, clientHeight } = this.node;
|
||||||
const offset = scrollHeight - scrollTop - clientHeight;
|
const offset = scrollHeight - scrollTop - clientHeight;
|
||||||
|
|
||||||
if (400 > offset && this.props.onScrollToBottom && !this.props.isLoading) {
|
if (400 > offset && this.props.onLoadMore && !this.props.isLoading) {
|
||||||
this.props.onScrollToBottom();
|
this.props.onLoadMore();
|
||||||
} else if (scrollTop < 100 && this.props.onScrollToTop) {
|
}
|
||||||
|
|
||||||
|
if (scrollTop < 100 && this.props.onScrollToTop) {
|
||||||
this.props.onScrollToTop();
|
this.props.onScrollToTop();
|
||||||
} else if (this.props.onScroll) {
|
} else if (this.props.onScroll) {
|
||||||
this.props.onScroll();
|
this.props.onScroll();
|
||||||
|
@ -144,7 +146,7 @@ export default class ScrollableList extends PureComponent {
|
||||||
|
|
||||||
handleLoadMore = (e) => {
|
handleLoadMore = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.onScrollToBottom();
|
this.props.onLoadMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
scrollKey: PropTypes.string.isRequired,
|
scrollKey: PropTypes.string.isRequired,
|
||||||
statusIds: ImmutablePropTypes.list.isRequired,
|
statusIds: ImmutablePropTypes.list.isRequired,
|
||||||
featuredStatusIds: ImmutablePropTypes.list,
|
featuredStatusIds: ImmutablePropTypes.list,
|
||||||
onScrollToBottom: PropTypes.func,
|
onLoadMore: PropTypes.func,
|
||||||
onScrollToTop: PropTypes.func,
|
onScrollToTop: PropTypes.func,
|
||||||
onScroll: PropTypes.func,
|
onScroll: PropTypes.func,
|
||||||
trackScroll: PropTypes.bool,
|
trackScroll: PropTypes.bool,
|
||||||
|
|
|
@ -56,7 +56,7 @@ export default class AccountTimeline extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = () => {
|
handleLoadMore = () => {
|
||||||
if (!this.props.isLoading && this.props.hasMore) {
|
if (!this.props.isLoading && this.props.hasMore) {
|
||||||
this.props.dispatch(expandAccountTimeline(this.props.params.accountId, this.props.withReplies));
|
this.props.dispatch(expandAccountTimeline(this.props.params.accountId, this.props.withReplies));
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ export default class AccountTimeline extends ImmutablePureComponent {
|
||||||
featuredStatusIds={featuredStatusIds}
|
featuredStatusIds={featuredStatusIds}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class Bookmarks extends ImmutablePureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadMore = debounce(() => {
|
||||||
this.props.dispatch(expandBookmarkedStatuses());
|
this.props.dispatch(expandBookmarkedStatuses());
|
||||||
}, 300, { leading: true })
|
}, 300, { leading: true })
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default class Bookmarks extends ImmutablePureComponent {
|
||||||
scrollKey={`bookmarked_statuses-${columnId}`}
|
scrollKey={`bookmarked_statuses-${columnId}`}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class Favourites extends ImmutablePureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadMore = debounce(() => {
|
||||||
this.props.dispatch(expandFavouritedStatuses());
|
this.props.dispatch(expandFavouritedStatuses());
|
||||||
}, 300, { leading: true })
|
}, 300, { leading: true })
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default class Favourites extends ImmutablePureComponent {
|
||||||
scrollKey={`favourited_statuses-${columnId}`}
|
scrollKey={`favourited_statuses-${columnId}`}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default class Notifications extends React.PureComponent {
|
||||||
trackScroll: true,
|
trackScroll: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadMore = debounce(() => {
|
||||||
this.props.dispatch(scrollTopNotifications(false));
|
this.props.dispatch(scrollTopNotifications(false));
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
}, 300, { leading: true });
|
}, 300, { leading: true });
|
||||||
|
@ -153,7 +153,7 @@ export default class Notifications extends React.PureComponent {
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
emptyMessage={emptyMessage}
|
emptyMessage={emptyMessage}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
onScrollToTop={this.handleScrollToTop}
|
onScrollToTop={this.handleScrollToTop}
|
||||||
onScroll={this.handleScroll}
|
onScroll={this.handleScroll}
|
||||||
shouldUpdateScroll={shouldUpdateScroll}
|
shouldUpdateScroll={shouldUpdateScroll}
|
||||||
|
|
|
@ -60,10 +60,7 @@ const makeMapStateToProps = () => {
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { timelineId, loadMore }) => ({
|
const mapDispatchToProps = (dispatch, { timelineId, loadMore }) => ({
|
||||||
|
|
||||||
onScrollToBottom: debounce(() => {
|
onLoadMore: debounce(loadMore, 300, { leading: true }),
|
||||||
dispatch(scrollTopTimeline(timelineId, false));
|
|
||||||
loadMore();
|
|
||||||
}, 300, { leading: true }),
|
|
||||||
|
|
||||||
onScrollToTop: debounce(() => {
|
onScrollToTop: debounce(() => {
|
||||||
dispatch(scrollTopTimeline(timelineId, true));
|
dispatch(scrollTopTimeline(timelineId, true));
|
||||||
|
|
Loading…
Reference in a new issue