diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-01-30 18:04:15 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-01-30 18:07:17 +0100 |
commit | 404d2050d3e96a05ec15e43f64cd24d5fca9e394 (patch) | |
tree | 410c3b5c3a79da9cd44f97ca0398e91b75efd209 /app/assets/javascripts/components/features | |
parent | 02cd2e42b245d7d81e4664729552fd94bb62b6d7 (diff) |
Add explicit "load more" link to the bottom of StatusList and notifications
Diffstat (limited to 'app/assets/javascripts/components/features')
-rw-r--r-- | app/assets/javascripts/components/features/notifications/index.jsx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/app/assets/javascripts/components/features/notifications/index.jsx b/app/assets/javascripts/components/features/notifications/index.jsx index b4593aaff..d3300acd5 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 = <LoadMore onClick={this.handleLoadMore} />; + } const scrollableArea = ( - <div className='scrollable' onScroll={this.handleScroll}> + <div className='scrollable' onScroll={this.handleScroll} ref={this.setRef}> <div> {notifications.map(item => <NotificationContainer key={item.get('id')} notification={item} accountId={item.get('account')} />)} + {loadMore} </div> </div> ); |