From 2044d32c67984e44f27df64d261b3eb6fc8db553 Mon Sep 17 00:00:00 2001 From: Julia Aranovich Date: Fri, 10 Feb 2017 12:02:30 +0400 Subject: [PATCH] Fetch only last notifications in notifications popover Related-Bug: #1657348 Depend-On: I7760465f70b3f69791e7a0c558a26e8ba55c934a Change-Id: I257cf6c9278743f7b7789b4d818bed8be9958cde --- static/views/layout.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/static/views/layout.js b/static/views/layout.js index b60aff17a..6230bec83 100644 --- a/static/views/layout.js +++ b/static/views/layout.js @@ -312,10 +312,13 @@ var NotificationsPopover = React.createClass({ this.updateNotifications(); }, updateNotifications() { - var {notifications} = this.props; - //FIXME(jkirnosova): need to fetch limited number of notifications - //according to visibleNotificationsNumber prop - return notifications.fetch().then(() => this.markAsRead()); + var {notifications, visibleNotificationsNumber} = this.props; + return notifications + .fetch({ + url: _.result(notifications, 'url') + '/?' + + $.param({limit: visibleNotificationsNumber, order_by: '-id'}) + }) + .then(() => this.markAsRead()); }, showNodeInfo(id) { this.props.toggle(false); @@ -375,7 +378,7 @@ var NotificationsPopover = React.createClass({ }, render() { var {loading} = this.state; - var {notifications, toggle, visibleNotificationsNumber} = this.props; + var {notifications, toggle} = this.props; var showMore = Backbone.history.getHash() !== 'notifications'; return ( @@ -383,7 +386,7 @@ var NotificationsPopover = React.createClass({ :
- {notifications.take(visibleNotificationsNumber).map(this.renderNotification)} + {notifications.map(this.renderNotification)} {showMore &&
{i18n('notifications_popover.view_all_button')}