Interactive interface for browsing global, full-resolution satellite imagery
fix event unavailable alert issue
Jason Kent3eea4ab66989
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.jsindex d93199bbc..4aaf6ad8a 100644--- a/web/js/containers/sidebar/events.js+++ b/web/js/containers/sidebar/events.js@@ -73,9 +73,10 @@ function Events(props) {initRequests();}- if (selected.id && !visibleWithinMapExtent[selected.id] && events && events.length) {+ if (selected.id && selected.date && !visibleWithinMapExtent[selected.id] && events && events.length) {deselectEvent();}+const errorOrLoadingText = isLoading? 'Loading...': hasRequestError@@ -167,7 +168,7 @@ const mapDispatchToProps = (dispatch) => ({dispatch(selectDate(new Date(dateStr)));}},- deselectEvent: (id, date) => {+ deselectEvent: () => {dispatch(deselectEventActionCreator());},requestEvents: (url) => {diff --git a/web/js/map/natural-events/track.js b/web/js/map/natural-events/track.jsindex eaed22cc3..11c5fb13d 100644--- a/web/js/map/natural-events/track.js+++ b/web/js/map/natural-events/track.js@@ -13,7 +13,6 @@ import {debounce as lodashDebounce,} from 'lodash';-import { naturalEventsUtilGetEventById } from './util';import {naturalEventsClusterPointToGeoJSON,naturalEventsClusterGetPoints,@@ -30,6 +29,7 @@ export default function naturalEventsTrack(ui, store, selectedMap) {const self = {};self.trackDetails = {};self.active = false;+/*** @return {void}*/@@ -161,16 +161,13 @@ export default function naturalEventsTrack(ui, store, selectedMap) {};const debounceTrackUpdate = lodashDebounce(() => {- const selectedEvent = ui.naturalEvents.selected;+ const { eventsData, selected } = ui.naturalEvents;- if (!selectedEvent.id || !selectedEvent.date) {+ if (!selected.id || !selected.date) {return;}- const event = naturalEventsUtilGetEventById(- ui.naturalEvents.eventsData,- selectedEvent.id,- );- self.update(event, selectedEvent.date, (id, date) => {+ const event = eventsData.find((e) => e.id === selected.id);+ self.update(event, selected.date, (id, date) => {store.dispatch(selectEventAction(id, date));});}, 250);diff --git a/web/js/map/natural-events/ui.js b/web/js/map/natural-events/ui.jsindex a5b907a66..2c4b66cf5 100644--- a/web/js/map/natural-events/ui.js+++ b/web/js/map/natural-events/ui.js@@ -8,11 +8,8 @@ import util from '../../util/util';import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../../modules/sidebar/constants';import * as EVENT_CONSTANTS from '../../modules/natural-events/constants';import { activateLayersForEventCategory } from '../../modules/layers/actions';-import {- deselectEvent as deselectEventAction,- selected as selectedAction,-} from '../../modules/natural-events/actions';-import { getDefaultEventDate, naturalEventsUtilGetEventById } from './util';+import { selected as selectedAction } from '../../modules/natural-events/actions';+import { getDefaultEventDate } from './util';import { selectDate } from '../../modules/date/actions';import { UPDATE_MAP_UI } from '../../modules/map/constants';import { LOCATION_POP_ACTION } from '../../redux-location-state-customs';@@ -166,7 +163,7 @@ export default function naturalEventsUI(ui, config, store, models) {filterEventList();}if (self.selected.date) {- const event = naturalEventsUtilGetEventById(self.eventsData, self.selected.id);+ const event = self.eventsData.find((e) => e.id === self.selected.id);setTimeout(() => {naturalEventsTrack.update(event, self.selected.date);zoomToEvent(event, self.selected.date, null, false);@@ -244,9 +241,9 @@ export default function naturalEventsUI(ui, config, store, models) {const selectEvent = function(id, date, rotation, isInitialLoad) {const isIdChange = !self.selected || self.selected.id !== id;const prevId = self.selected.id ? self.selected.id : false;- const prevEvent = prevId && naturalEventsUtilGetEventById(self.eventsData, prevId);+ const prevEvent = prevId && self.eventsData.find((e) => e.id === prevId);const prevCategory = prevEvent ? prevEvent.categories[0].title : false;- const event = naturalEventsUtilGetEventById(self.eventsData, id);+ const event = self.eventsData.find((e) => e.id === id);const category = event && event.categories[0].title;const isSameCategory = category === prevCategory;if (!event) {@@ -314,7 +311,7 @@ export default function naturalEventsUI(ui, config, store, models) {self.markers = naturalEventMarkers.draw();naturalEventsTrack.update(null);}- store.dispatch(deselectEventAction);+ // store.dispatch(deselectEventAction);self.events.trigger('change');};diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.jsindex 9ee13c2ba..17ce3ded4 100644--- a/web/js/map/natural-events/util.js+++ b/web/js/map/natural-events/util.js@@ -2,18 +2,6 @@ import lodashFind from 'lodash/find';import * as olProj from 'ol/proj';import * as olExtent from 'ol/extent';-/**- * Find event in array of events- * using event id- *- * @param {Array} events Array of Eonet Events- * @param {String} id Event Id- * @return {Object} Eonet Event Object- */-export function naturalEventsUtilGetEventById(events, id) {- return lodashFind(events, (e) => e.id === id);-}-/**** @param {*} eventdiff --git a/web/js/modules/natural-events/actions.js b/web/js/modules/natural-events/actions.jsindex 5d2b35af9..30e4e6234 100644--- a/web/js/modules/natural-events/actions.js+++ b/web/js/modules/natural-events/actions.js@@ -47,8 +47,6 @@ export function selectEvent(id, date) {export function deselectEvent(id, date) {return {type: DESELECT_EVENT,- id,- date,};}