Fetch only last notifications in notifications popover
Related-Bug: #1657348 Depend-On: I7760465f70b3f69791e7a0c558a26e8ba55c934a Change-Id: I257cf6c9278743f7b7789b4d818bed8be9958cde
This commit is contained in:
parent
b81ee34324
commit
2044d32c67
|
@ -312,10 +312,13 @@ var NotificationsPopover = React.createClass({
|
||||||
this.updateNotifications();
|
this.updateNotifications();
|
||||||
},
|
},
|
||||||
updateNotifications() {
|
updateNotifications() {
|
||||||
var {notifications} = this.props;
|
var {notifications, visibleNotificationsNumber} = this.props;
|
||||||
//FIXME(jkirnosova): need to fetch limited number of notifications
|
return notifications
|
||||||
//according to visibleNotificationsNumber prop
|
.fetch({
|
||||||
return notifications.fetch().then(() => this.markAsRead());
|
url: _.result(notifications, 'url') + '/?' +
|
||||||
|
$.param({limit: visibleNotificationsNumber, order_by: '-id'})
|
||||||
|
})
|
||||||
|
.then(() => this.markAsRead());
|
||||||
},
|
},
|
||||||
showNodeInfo(id) {
|
showNodeInfo(id) {
|
||||||
this.props.toggle(false);
|
this.props.toggle(false);
|
||||||
|
@ -375,7 +378,7 @@ var NotificationsPopover = React.createClass({
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
var {loading} = this.state;
|
var {loading} = this.state;
|
||||||
var {notifications, toggle, visibleNotificationsNumber} = this.props;
|
var {notifications, toggle} = this.props;
|
||||||
var showMore = Backbone.history.getHash() !== 'notifications';
|
var showMore = Backbone.history.getHash() !== 'notifications';
|
||||||
return (
|
return (
|
||||||
<Popover toggle={toggle} className='notifications-popover'>
|
<Popover toggle={toggle} className='notifications-popover'>
|
||||||
|
@ -383,7 +386,7 @@ var NotificationsPopover = React.createClass({
|
||||||
<ProgressBar />
|
<ProgressBar />
|
||||||
:
|
:
|
||||||
<div>
|
<div>
|
||||||
{notifications.take(visibleNotificationsNumber).map(this.renderNotification)}
|
{notifications.map(this.renderNotification)}
|
||||||
{showMore &&
|
{showMore &&
|
||||||
<div className='show-more'>
|
<div className='show-more'>
|
||||||
<Link to='/notifications'>{i18n('notifications_popover.view_all_button')}</Link>
|
<Link to='/notifications'>{i18n('notifications_popover.view_all_button')}</Link>
|
||||||
|
|
Loading…
Reference in New Issue