import { createSelector } from 'reselect';
import Immutable from 'immutable';
import LoadMore from '../../components/load_more';
+import { debounce } from 'lodash';
const messages = defineMessages({
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
trackScroll: true,
};
+ dispatchExpandNotifications = debounce(() => {
+ this.props.dispatch(expandNotifications());
+ }, 300, { leading: true });
+
+ dispatchScrollToTop = debounce((top) => {
+ this.props.dispatch(scrollTopNotifications(top));
+ }, 100);
+
handleScroll = (e) => {
const { scrollTop, scrollHeight, clientHeight } = e.target;
const offset = scrollHeight - scrollTop - clientHeight;
this._oldScrollPosition = scrollHeight - scrollTop;
- if (250 > offset && !this.props.isLoading) {
- if (this.props.hasMore) {
- this.props.dispatch(expandNotifications());
- }
- } else if (scrollTop < 100) {
- this.props.dispatch(scrollTopNotifications(true));
+ if (250 > offset && this.props.hasMore && !this.props.isLoading) {
+ this.dispatchExpandNotifications();
+ }
+
+ if (scrollTop < 100) {
+ this.dispatchScrollToTop(true);
} else {
- this.props.dispatch(scrollTopNotifications(false));
+ this.dispatchScrollToTop(false);
}
}
handleLoadMore = (e) => {
e.preventDefault();
- this.props.dispatch(expandNotifications());
+ this.dispatchExpandNotifications();
}
handlePin = () => {