Interactive interface for browsing global, full-resolution satellite imagery
Add checks for localStorage & remove hideTour checkbox if no localStorage
ZachTRice6463f27ea19e
diff --git a/web/js/alert/ui.js b/web/js/alert/ui.jsindex 46fef14c5..65c89db30 100644--- a/web/js/alert/ui.js+++ b/web/js/alert/ui.js@@ -1,6 +1,7 @@import React from 'react';import ReactDOM from 'react-dom';import TourAlert from '../components/alert/alert-tour';+import util from '../util/util';export function alertUi(ui) {var self = {};@@ -21,6 +22,7 @@ export function alertUi(ui) {};self.showTourAlert = function(e) {+ if (!util.browser.localStorage) return;var hideTour = localStorage.getItem('hideTour');if (!hideTour) return;diff --git a/web/js/components/tour/modal-tour-start.js b/web/js/components/tour/modal-tour-start.jsindex c02c2ba9b..524d386ab 100644--- a/web/js/components/tour/modal-tour-start.js+++ b/web/js/components/tour/modal-tour-start.js@@ -3,12 +3,13 @@ import PropTypes from 'prop-types';import { Modal, ModalHeader, ModalBody, ModalFooter, InputGroup, InputGroupText, Input } from 'reactstrap';import TourIntro from './content-intro';import TourBoxes from './tour-boxes';+import util from '../../util/util';class ModalStart extends React.Component {constructor(props) {super(props);this.state = {- checked: localStorage.hideTour+ checked: this.props.storageCheck};this.setWrapperRef = this.setWrapperRef.bind(this);@@ -68,6 +69,7 @@ class ModalStart extends React.Component {<TourIntro toggleModalStart={this.props.toggleModalStart}></TourIntro><TourBoxes stories={this.props.stories} storyOrder={this.props.storyOrder} selectTour={this.props.selectTour}></TourBoxes></ModalBody>+ {util.browser.localStorage &&<ModalFooter><InputGroup><InputGroupText className="w-100">@@ -76,6 +78,7 @@ class ModalStart extends React.Component {</InputGroupText></InputGroup></ModalFooter>+ }</Modal>);}@@ -90,6 +93,7 @@ ModalStart.propTypes = {showTourAlert: PropTypes.func.isRequired,hideTour: PropTypes.func.isRequired,showTour: PropTypes.func.isRequired,+ storageCheck: PropTypes.bool.isRequired,className: PropTypes.string};diff --git a/web/js/components/tour/tour.js b/web/js/components/tour/tour.jsindex ffa71a1ea..7facad398 100644--- a/web/js/components/tour/tour.js+++ b/web/js/components/tour/tour.js@@ -132,6 +132,7 @@ class Tour extends React.Component {showTourAlert={this.props.showTourAlert}hideTour={this.props.hideTour}showTour={this.props.showTour}+ storageCheck={this.props.storageCheck}></TourStart><TourInProgress@@ -197,7 +198,8 @@ Tour.propTypes = {hideTour: PropTypes.func.isRequired,showTour: PropTypes.func.isRequired,restartTour: PropTypes.bool.isRequired,- metaLoaded: PropTypes.bool.isRequired+ metaLoaded: PropTypes.bool.isRequired,+ storageCheck: PropTypes.bool.isRequired};export default Tour;diff --git a/web/js/notifications/ui.js b/web/js/notifications/ui.jsindex 86da8c953..cdf050561 100644--- a/web/js/notifications/ui.js+++ b/web/js/notifications/ui.js@@ -31,9 +31,7 @@ export function notificationsUi(models, config) {*/var init = function () {var p;- if (!util.browser.localStorage) {- return;- }+ if (!util.browser.localStorage) return;if (config.parameters.mockAlerts) {url = 'mock/notify_' + config.parameters.mockAlerts + '.json';}diff --git a/web/js/tour/ui.js b/web/js/tour/ui.jsindex aada06250..9b9c7e6af 100644--- a/web/js/tour/ui.js+++ b/web/js/tour/ui.js@@ -54,15 +54,30 @@ export function tourUi(models, ui, config) {selectTour: self.selectTour,showTourAlert: ui.alert.showTourAlert,hideTour: self.hideTour,- showTour: self.showTour+ showTour: self.showTour,+ storageCheck: self.storageChecked()};};+ self.storageChecked = function() {+ if (!util.browser.localStorage) {+ return false;+ } else {+ // Do the opposite of the results of checking the build timestamp / setting modalStart+ // i.e. Checking hide means (true) not showing the start modal+ if (self.checkBuildTimestamp() === true) {+ return false;+ } else {+ return true;+ }+ }+ };+self.checkBuildTimestamp = function() {+ // If there is no localStorage, always show the tour start modal+ if (!util.browser.localStorage) return true;var hideTour = localStorage.getItem('hideTour');- if (!util.browser.localStorage) return;-// Don't start tour if coming in via a permalinkif (window.location.search && !config.parameters.tour) {return false;@@ -137,6 +152,7 @@ export function tourUi(models, ui, config) {};self.hideTour = function(e) {+ if (!util.browser.localStorage) return;var hideTour = localStorage.getItem('hideTour');// Checkbox to "hide tour modal until a new story has been added" has been checked@@ -144,13 +160,13 @@ export function tourUi(models, ui, config) {'event': 'tour_hide_checked'});- if (!util.browser.localStorage) return;if (hideTour) return;localStorage.setItem('hideTour', new Date());};self.showTour = function(e) {+ if (!util.browser.localStorage) return;var hideTour = localStorage.getItem('hideTour');// Checkbox to "hide tour modal until a new story has been added" has been checked@@ -158,7 +174,6 @@ export function tourUi(models, ui, config) {'event': 'tour_hide_unchecked'});- if (!util.browser.localStorage) return;if (!hideTour) return;localStorage.removeItem('hideTour');