diff --git a/app/assets/stylesheets/notifications.scss.erb b/app/assets/stylesheets/notifications.scss.erb index f6d01dc8..4c97547b 100644 --- a/app/assets/stylesheets/notifications.scss.erb +++ b/app/assets/stylesheets/notifications.scss.erb @@ -149,7 +149,7 @@ $unread_notifications_dot_size: 8px; ul.notifications { list-style: none; - li:last-child { + li:nth-last-child(2) { .notification-body { border-bottom: none !important; } diff --git a/frontend/src/Metamaps/GlobalUI/Notifications.js b/frontend/src/Metamaps/GlobalUI/Notifications.js index 0d2e5271..fef31602 100644 --- a/frontend/src/Metamaps/GlobalUI/Notifications.js +++ b/frontend/src/Metamaps/GlobalUI/Notifications.js @@ -30,7 +30,7 @@ const Notifications = { method: 'PUT', success: function(r) { if (n) { - + Notifications.unreadNotificationsCount-- n.is_read = true render() } diff --git a/frontend/src/components/App/NotificationBox.js b/frontend/src/components/App/NotificationBox.js index 01382f26..3df31e7c 100644 --- a/frontend/src/components/App/NotificationBox.js +++ b/frontend/src/components/App/NotificationBox.js @@ -26,29 +26,48 @@ class NotificationBox extends Component { this.props.toggleNotificationsBox() } - render = () => { + hasSomeNotifications = () => { + const { notifications } = this.props + return notifications && notifications.length > 0 + } + + showLoading = () => { + return
  • + } + + showEmpty = () => { + return
  • + You have no notifications.
    + More time for dancing. +
  • + } + + showNotifications = () => { const { notifications, markAsRead, markAsUnread } = this.props - const empty = notifications && notifications.length === 0 + if (!this.hasSomeNotifications()) { + return this.showEmpty() + } + return notifications.slice(0, 10).map( + n => + ).concat([ +
  • + + See all + +
  • + ]) + } + + render = () => { + const { notifications } = this.props return
      - {!notifications &&
    • } - {empty ? ( -
    • - You have no notifications.
      - More time for dancing. -
    • - ) : ( - notifications.slice(0, 10).map(n => ) - )} + {notifications ? this.showNotifications() : this.showLoading()}
    - {notifications && !empty && - See all - }
    } }