diff --git a/src/Metamaps/GlobalUI/Notifications.js b/src/Metamaps/GlobalUI/Notifications.js index b907d00c..2ed7238d 100644 --- a/src/Metamaps/GlobalUI/Notifications.js +++ b/src/Metamaps/GlobalUI/Notifications.js @@ -4,16 +4,23 @@ import GlobalUI from './index' const Notifications = { notifications: [], + notificationsLoading: false, unreadNotificationsCount: 0, init: serverData => { Notifications.unreadNotificationsCount = serverData.unreadNotificationsCount }, fetchNotifications: render => { + Notifications.notificationsLoading = true + render() $.ajax({ url: '/notifications.json', success: function(data) { Notifications.notifications = data + Notifications.notificationsLoading = false render() + }, + error: function() { + GlobalUI.notifyUser('There was an error fetching notifications') } }) }, diff --git a/src/Metamaps/GlobalUI/ReactApp.js b/src/Metamaps/GlobalUI/ReactApp.js index b3dc3697..cb5dc947 100644 --- a/src/Metamaps/GlobalUI/ReactApp.js +++ b/src/Metamaps/GlobalUI/ReactApp.js @@ -53,7 +53,6 @@ const ReactApp = { switch (pathname.split('/')[1]) { case '': if (Active.Mapper && Active.Mapper.id) { - $('#yield').hide() ExploreMaps.updateFromPath(pathname) self.mapId = null Active.Map = null @@ -61,7 +60,6 @@ const ReactApp = { } break case 'explore': - $('#yield').hide() ExploreMaps.updateFromPath(pathname) self.mapId = null self.topicId = null @@ -69,21 +67,18 @@ const ReactApp = { Active.Topic = null break case 'topics': - $('#yield').hide() Active.Map = null self.mapId = null self.topicId = pathname.split('/')[2] break case 'maps': if (!pathname.includes('request_access')) { - $('#yield').hide() Active.Topic = null self.topicId = null self.mapId = pathname.split('/')[2] } break default: - $('#yield').show() break } self.render() @@ -108,6 +103,7 @@ const ReactApp = { openInviteLightbox: () => self.openLightbox('invite'), serverData: self.serverData, notifications: Notifications.notifications, + notificationsLoading: Notifications.notificationsLoading, fetchNotifications: apply(Notifications.fetchNotifications, ReactApp.render), fetchNotification: apply(Notifications.fetchNotification, ReactApp.render), markAsRead: apply(Notifications.markAsRead, ReactApp.render), diff --git a/src/components/NotificationBox.js b/src/components/NotificationBox.js index b2315cee..fdb836f6 100644 --- a/src/components/NotificationBox.js +++ b/src/components/NotificationBox.js @@ -9,6 +9,7 @@ import Loading from './Loading' class NotificationBox extends Component { static propTypes = { notifications: PropTypes.array, + loading: PropTypes.bool.isRequired, fetchNotifications: PropTypes.func.isRequired, toggleNotificationsBox: PropTypes.func.isRequired, markAsRead: PropTypes.func.isRequired, @@ -60,11 +61,11 @@ class NotificationBox extends Component { } render = () => { - const { notifications } = this.props + const { loading } = this.props return