Updated StatusList, ScrollableList to use given props
• Updated: - StatusList, ScrollableList to use given props • Fixed: - Issue with scrolling back to top onLoadMore
This commit is contained in:
parent
c66d05df36
commit
4a8ddd5803
@ -228,8 +228,6 @@ export default class ScrollableList extends PureComponent {
|
|||||||
} = this.props
|
} = this.props
|
||||||
const childrenCount = React.Children.count(children);
|
const childrenCount = React.Children.count(children);
|
||||||
|
|
||||||
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null
|
|
||||||
|
|
||||||
if (showLoading) {
|
if (showLoading) {
|
||||||
if (Placeholder) {
|
if (Placeholder) {
|
||||||
return (
|
return (
|
||||||
@ -248,9 +246,7 @@ export default class ScrollableList extends PureComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <ColumnIndicator type='loading' />
|
||||||
<ColumnIndicator type='loading' />
|
|
||||||
)
|
|
||||||
} else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) {
|
} else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) {
|
||||||
return (
|
return (
|
||||||
<div onMouseMove={this.handleMouseMove}>
|
<div onMouseMove={this.handleMouseMove}>
|
||||||
@ -278,14 +274,18 @@ export default class ScrollableList extends PureComponent {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
{loadMore}
|
{
|
||||||
|
(hasMore && onLoadMore && !isLoading) &&
|
||||||
|
<LoadMore onClick={this.handleLoadMore} />
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
isLoading &&
|
isLoading &&
|
||||||
<ColumnIndicator type='loading' />
|
<ColumnIndicator type='loading' />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -224,11 +224,15 @@ class StatusList extends ImmutablePureComponent {
|
|||||||
isPartial,
|
isPartial,
|
||||||
group,
|
group,
|
||||||
promotedStatuses,
|
promotedStatuses,
|
||||||
...other
|
scrollKey,
|
||||||
|
hasMore,
|
||||||
|
emptyMessage,
|
||||||
|
onScrollToTop,
|
||||||
|
onScroll,
|
||||||
} = this.props
|
} = this.props
|
||||||
const { fetchedContext, refreshing } = this.state
|
const { fetchedContext, refreshing } = this.state
|
||||||
|
|
||||||
if (isPartial || isLoading && statusIds.size === 0) {
|
if (isPartial || (isLoading && statusIds.size === 0)) {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<StatusPlaceholder />
|
<StatusPlaceholder />
|
||||||
@ -320,10 +324,16 @@ class StatusList extends ImmutablePureComponent {
|
|||||||
<ScrollableList
|
<ScrollableList
|
||||||
ref={this.setRef}
|
ref={this.setRef}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={(isLoading && statusIds.size === 0) || refreshing}
|
showLoading={(isLoading && statusIds.size === 0)}
|
||||||
onLoadMore={onLoadMore && this.handleLoadOlder}
|
onLoadMore={onLoadMore && this.handleLoadOlder}
|
||||||
onReload={this.handleOnReload}
|
onReload={this.handleOnReload}
|
||||||
{...other}
|
placeholderComponent={StatusPlaceholder}
|
||||||
|
placeholderCount={1}
|
||||||
|
scrollKey={scrollKey}
|
||||||
|
hasMore={hasMore}
|
||||||
|
emptyMessage={emptyMessage}
|
||||||
|
onScrollToTop={onScrollToTop}
|
||||||
|
onScroll={onScroll}
|
||||||
>
|
>
|
||||||
{scrollableContent}
|
{scrollableContent}
|
||||||
</ScrollableList>
|
</ScrollableList>
|
||||||
|
@ -87,7 +87,6 @@ class AccountTimeline extends ImmutablePureComponent {
|
|||||||
statusIds={statusIds}
|
statusIds={statusIds}
|
||||||
featuredStatusIds={featuredStatusIds}
|
featuredStatusIds={featuredStatusIds}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
showLoading={isLoading}
|
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={intl.formatMessage(messages.empty)}
|
emptyMessage={intl.formatMessage(messages.empty)}
|
||||||
|
@ -34,7 +34,6 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
params: PropTypes.object.isRequired,
|
params: PropTypes.object.isRequired,
|
||||||
dispatch: PropTypes.func.isRequired,
|
dispatch: PropTypes.func.isRequired,
|
||||||
columnId: PropTypes.string,
|
|
||||||
hasUnread: PropTypes.bool,
|
hasUnread: PropTypes.bool,
|
||||||
group: PropTypes.oneOfType([
|
group: PropTypes.oneOfType([
|
||||||
ImmutablePropTypes.map,
|
ImmutablePropTypes.map,
|
||||||
@ -77,7 +76,7 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { columnId, group, relationships, account, intl } = this.props
|
const { group, relationships, account, intl } = this.props
|
||||||
const { collapsed } = this.state
|
const { collapsed } = this.state
|
||||||
const { id } = this.props.params
|
const { id } = this.props.params
|
||||||
|
|
||||||
@ -90,7 +89,7 @@ class GroupTimeline extends ImmutablePureComponent {
|
|||||||
return (
|
return (
|
||||||
<StatusList
|
<StatusList
|
||||||
alwaysPrepend
|
alwaysPrepend
|
||||||
scrollKey={`group_timeline-${columnId}`}
|
scrollKey={`group_timeline-${id}`}
|
||||||
timelineId={`group:${id}`}
|
timelineId={`group:${id}`}
|
||||||
onLoadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
group={group}
|
group={group}
|
||||||
|
@ -38,9 +38,7 @@ class Shortcuts extends ImmutablePureComponent {
|
|||||||
shortcuts,
|
shortcuts,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
if (isLoading) {
|
if (isError) {
|
||||||
return <ColumnIndicator type='loading' />
|
|
||||||
} else if (isError) {
|
|
||||||
return <ColumnIndicator type='error' message='Error fetching shortcuts' />
|
return <ColumnIndicator type='error' message='Error fetching shortcuts' />
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +53,7 @@ class Shortcuts extends ImmutablePureComponent {
|
|||||||
scrollKey='shortcuts'
|
scrollKey='shortcuts'
|
||||||
emptyMessage='You have no shortcuts'
|
emptyMessage='You have no shortcuts'
|
||||||
items={listItems}
|
items={listItems}
|
||||||
|
showLoading={isLoading}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user