Skip to content

Instantly share code, notes, and snippets.

@ralfting
Created November 13, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfting/4487ca2b6e93a47d15bab26a04bec4a0 to your computer and use it in GitHub Desktop.
Save ralfting/4487ca2b6e93a47d15bab26a04bec4a0 to your computer and use it in GitHub Desktop.
// @flow
import * as React from 'react';
import { Timeline, Sidebar, EmptyStates } from 'pipestyle';
import { t } from 'utils/I18n';
import ActivityItem from './ActivityItem';
import FakeActivities from './FakeActivities';
export default class PipeActivities extends React.Component {
componentDidMount() {
this.props.subscribeToMore();
}
throttle = (event) => throttle(() => this.onScroll(event), 100)
onScroll = e => {
const { loading, hasMore, fetchMore } = this.props;
if (loading || !hasMore) return;
const node = e.target;
const isScrollEnd = node.offsetHeight + node.scrollTop >= node.scrollHeight;
if (isScrollEnd) {
fetchMore();
}
};
render() {
const { onClose, activities, loading } = this.props;
return (
<Sidebar
title={t('activities.pipe_timeline._title')}
isActive={true}
onClickClose={onClose}
onScroll={this.throttle}
>
<Timeline className="pp-no-padding">
// [...]
</Timeline>
</Sidebar>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment