From 404d2050d3e96a05ec15e43f64cd24d5fca9e394 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 30 Jan 2017 18:04:15 +0100 Subject: [PATCH] Add explicit "load more" link to the bottom of StatusList and notifications --- .../components/components/avatar.jsx | 4 +-- .../components/components/load_more.jsx | 21 ++++++++++++++ .../components/components/status.jsx | 2 +- .../components/components/status_list.jsx | 16 ++++++++++- .../features/notifications/index.jsx | 28 +++++++++++++++++-- app/assets/stylesheets/components.scss | 6 ++++ 6 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/components/components/load_more.jsx diff --git a/app/assets/javascripts/components/components/avatar.jsx b/app/assets/javascripts/components/components/avatar.jsx index ee9fc72556..f912d9a99d 100644 --- a/app/assets/javascripts/components/components/avatar.jsx +++ b/app/assets/javascripts/components/components/avatar.jsx @@ -131,8 +131,8 @@ const Avatar = React.createClass({ return (
- - + +
); } diff --git a/app/assets/javascripts/components/components/load_more.jsx b/app/assets/javascripts/components/components/load_more.jsx new file mode 100644 index 0000000000..1866fc1001 --- /dev/null +++ b/app/assets/javascripts/components/components/load_more.jsx @@ -0,0 +1,21 @@ +import { FormattedMessage } from 'react-intl'; + +const loadMoreStyle = { + display: 'block', + color: '#616b86', + textAlign: 'center', + padding: '15px', + textDecoration: 'none' +}; + +const LoadMore = ({ onClick }) => ( + + + +); + +LoadMore.propTypes = { + onClick: React.PropTypes.func +}; + +export default LoadMore; diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx index df5f0f2c24..21adfd5789 100644 --- a/app/assets/javascripts/components/components/status.jsx +++ b/app/assets/javascripts/components/components/status.jsx @@ -73,7 +73,7 @@ const Status = React.createClass({ return (
-
+
}} />
diff --git a/app/assets/javascripts/components/components/status_list.jsx b/app/assets/javascripts/components/components/status_list.jsx index 69cc013f2f..8223a312c1 100644 --- a/app/assets/javascripts/components/components/status_list.jsx +++ b/app/assets/javascripts/components/components/status_list.jsx @@ -3,6 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import PureRenderMixin from 'react-addons-pure-render-mixin'; import { ScrollContainer } from 'react-router-scroll'; import StatusContainer from '../containers/status_container'; +import LoadMore from './load_more'; const StatusList = React.createClass({ @@ -63,8 +64,19 @@ const StatusList = React.createClass({ this.node = c; }, + handleLoadMore (e) { + e.preventDefault(); + this.props.onScrollToBottom(); + }, + render () { - const { statusIds, onScrollToBottom, trackScroll } = this.props; + const { statusIds, onScrollToBottom, trackScroll, isLoading } = this.props; + + let loadMore = ''; + + if (!isLoading && statusIds.size > 0) { + loadMore = ; + } const scrollableArea = (
@@ -72,6 +84,8 @@ const StatusList = React.createClass({ {statusIds.map((statusId) => { return ; })} + + {loadMore}
); diff --git a/app/assets/javascripts/components/features/notifications/index.jsx b/app/assets/javascripts/components/features/notifications/index.jsx index b4593aaff5..d3300acd5a 100644 --- a/app/assets/javascripts/components/features/notifications/index.jsx +++ b/app/assets/javascripts/components/features/notifications/index.jsx @@ -9,6 +9,7 @@ import { defineMessages, injectIntl } from 'react-intl'; import ColumnSettingsContainer from './containers/column_settings_container'; import { createSelector } from 'reselect'; import Immutable from 'immutable'; +import LoadMore from '../../components/load_more'; const messages = defineMessages({ title: { id: 'column.notifications', defaultMessage: 'Notifications' } @@ -45,19 +46,42 @@ const Notifications = React.createClass({ handleScroll (e) { const { scrollTop, scrollHeight, clientHeight } = e.target; const offset = scrollHeight - scrollTop - clientHeight; + this._oldScrollPosition = scrollHeight - scrollTop; if (250 > offset && !this.props.isLoading) { this.props.dispatch(expandNotifications()); } }, + componentDidUpdate (prevProps) { + if (this.node.scrollTop > 0 && (prevProps.notifications.size < this.props.notifications.size && prevProps.notifications.first() !== this.props.notifications.first() && !!this._oldScrollPosition)) { + this.node.scrollTop = this.node.scrollHeight - this._oldScrollPosition; + } + }, + + handleLoadMore (e) { + e.preventDefault(); + this.props.dispatch(expandNotifications()); + }, + + setRef (c) { + this.node = c; + }, + render () { - const { intl, notifications, trackScroll } = this.props; + const { intl, notifications, trackScroll, isLoading } = this.props; + + let loadMore = ''; + + if (!isLoading && notifications.size > 0) { + loadMore = ; + } const scrollableArea = ( -
+
{notifications.map(item => )} + {loadMore}
); diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss index a09021a120..6810fae12e 100644 --- a/app/assets/stylesheets/components.scss +++ b/app/assets/stylesheets/components.scss @@ -743,3 +743,9 @@ button.active i.fa-retweet { background: lighten($color1, 6%); } } + +.load-more { + &:hover { + background: lighten($color1, 6%); + } +}