Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes to scrollable lists and media gallery #9501

Merged
merged 5 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions app/javascript/mastodon/components/scrollable_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class ScrollableList extends PureComponent {
hasMore: PropTypes.bool,
prepend: PropTypes.node,
alwaysPrepend: PropTypes.bool,
alwaysShowScrollbar: PropTypes.bool,
emptyMessage: PropTypes.node,
children: PropTypes.node,
};
Expand Down Expand Up @@ -206,11 +205,11 @@ export default class ScrollableList extends PureComponent {
}

render () {
const { children, scrollKey, trackScroll, shouldUpdateScroll, showLoading, isLoading, hasMore, prepend, alwaysPrepend, alwaysShowScrollbar, emptyMessage, onLoadMore } = this.props;
const { children, scrollKey, trackScroll, shouldUpdateScroll, showLoading, isLoading, hasMore, prepend, alwaysPrepend, emptyMessage, onLoadMore } = this.props;
const { fullscreen } = this.state;
const childrenCount = React.Children.count(children);

const loadMore = (hasMore && childrenCount > 0 && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
let scrollableArea = null;

if (showLoading) {
Expand All @@ -225,7 +224,7 @@ export default class ScrollableList extends PureComponent {
</div>
</div>
);
} else if (isLoading || childrenCount > 0 || !emptyMessage) {
} else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) {
scrollableArea = (
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef} onMouseMove={this.handleMouseMove}>
<div role='feed' className='item-list'>
Expand All @@ -249,10 +248,8 @@ export default class ScrollableList extends PureComponent {
</div>
);
} else {
const scrollable = alwaysShowScrollbar;

scrollableArea = (
<div className={classNames({ scrollable, fullscreen })} ref={this.setRef} style={{ flex: '1 1 auto', display: 'flex', flexDirection: 'column' }}>
<div className={classNames('scrollable scrollable--flex', { fullscreen })} ref={this.setRef}>
{alwaysPrepend && prepend}

<div className='empty-column-indicator'>
Expand Down
17 changes: 12 additions & 5 deletions app/javascript/mastodon/features/account_gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LoadMoreMedia extends ImmutablePureComponent {
return (
<LoadMore
disabled={this.props.disabled}
onLoadMore={this.handleLoadMore}
onClick={this.handleLoadMore}
/>
);
}
Expand Down Expand Up @@ -103,23 +103,24 @@ class AccountGallery extends ImmutablePureComponent {
);
}

if (!isLoading && medias.size > 0 && hasMore) {
loadOlder = <LoadMore onClick={this.handleLoadOlder} />;
if (hasMore) {
loadOlder = <LoadMore visible={!isLoading} onClick={this.handleLoadOlder} />;
}

return (
<Column>
<ColumnBackButton />

<ScrollContainer scrollKey='account_gallery' shouldUpdateScroll={shouldUpdateScroll}>
<div className='scrollable' onScroll={this.handleScroll}>
<div className='scrollable scrollable--flex' onScroll={this.handleScroll}>
<HeaderContainer accountId={this.props.params.accountId} />

<div className='account-gallery__container'>
<div role='feed' className='account-gallery__container'>
{medias.map((media, index) => media === null ? (
<LoadMoreMedia
key={'more:' + medias.getIn(index + 1, 'id')}
maxId={index > 0 ? medias.getIn(index - 1, 'id') : null}
onLoadMore={this.handleLoadMore}
/>
) : (
<MediaItem
Expand All @@ -129,6 +130,12 @@ class AccountGallery extends ImmutablePureComponent {
))}
{loadOlder}
</div>

{isLoading && medias.size === 0 && (
<div className='scrollable__append'>
<LoadingIndicator />
</div>
)}
</div>
</ScrollContainer>
</Column>
Expand Down
1 change: 0 additions & 1 deletion app/javascript/mastodon/features/followers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Followers extends ImmutablePureComponent {
shouldUpdateScroll={shouldUpdateScroll}
prepend={<HeaderContainer accountId={this.props.params.accountId} hideTabs />}
alwaysPrepend
alwaysShowScrollbar
emptyMessage={emptyMessage}
>
{accountIds.map(id =>
Expand Down
1 change: 0 additions & 1 deletion app/javascript/mastodon/features/following/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Following extends ImmutablePureComponent {
shouldUpdateScroll={shouldUpdateScroll}
prepend={<HeaderContainer accountId={this.props.params.accountId} hideTabs />}
alwaysPrepend
alwaysShowScrollbar
emptyMessage={emptyMessage}
>
{accountIds.map(id =>
Expand Down