Interactive interface for browsing global, full-resolution satellite imagery
Remove unneeded check for `layer.period` in `prevDateInDateRange`
ZachTRice1c6fc696b1da
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.jsindex 6047b5a6b..c58b0e5d7 100644--- a/web/js/map/layerbuilder.js+++ b/web/js/map/layerbuilder.js@@ -110,13 +110,13 @@ export function mapLayerBuilder(models, config, cache, Parent) {date = models.date.selected;}- date = util.prevDateInDateRange(def, date, dateArray);+ date = util.prevDateInDateRange(date, dateArray);// Is current "rounded" previous date not in array of availableDatesif (date && !dateArray.includes(date)) {// Then, update layer object with new array of datesdef.availableDates = util.datesinDateRanges(def, date, true);- date = util.prevDateInDateRange(def, date, dateArray);+ date = util.prevDateInDateRange(date, dateArray);}dateId = date;var palette = '';diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 3b4927acb..bb94013f6 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -925,12 +925,11 @@ export default (function (self) {/*** Find the closest previous date from an array of dates*- * @param {object} def The layer object* @param {object} date A date to compare against the array of dates* @param {array} dateArray An array of dates* @return {object} The date object with normalized timeszone.*/- self.prevDateInDateRange = function (def, date, dateArray) {+ self.prevDateInDateRange = function (date, dateArray) {var currentDate = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));if (!dateArray) return date;@@ -945,10 +944,7 @@ export default (function (self) {// Find the closest dates within the current arrayvar closestDate = closestTo(currentDate, closestAvailableDates);- if (closestDate &&- ((def.period === 'yearly' && self.yearDiff(closestDate, currentDate) <= 1) ||- (def.period === 'monthly' && self.monthDiff(closestDate, currentDate) <= 1) ||- (def.period === 'daily' && self.dayDiff(closestDate, currentDate) <= 1))) {+ if (closestDate) {return closestDate;} else {return date;