Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

sync redux proj state with legacy proj state #1576

Benjamin King2187440ee19c
diff --git a/web/js/main.js b/web/js/main.js
index 2a9571915..24e0b7679 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -27,6 +27,7 @@ import { updateLegacyModule } from './modules/migration/actions';
import { validate as layerValidate } from './layers/layers';
import { polyfill } from './polyfill';
import { debugConfig } from './debug';
+import { changeProjection } from './modules/projection/actions';
const history = createBrowserHistory();
const isDevelop = !!(
@@ -94,16 +95,23 @@ const render = (config, parameters, legacyState) => {
getInitialState(models, config, parameters),
applyMiddleware(...middleware)
);
- lodashEach(models, function(component, i) {
+ lodashEach(models, function(component, key) {
if (component.load && !component.loaded) {
component.load(legacyState, errors);
}
const dispatchUpdate = lodashDebounce(() => {
- store.dispatch(updateLegacyModule(i, component));
+ store.dispatch(updateLegacyModule(key, component));
}, 100);
// sync old and new state
component.events.any(dispatchUpdate);
});
+ // Big HACKY sync up of proj state
+ models.proj.events.on('select', (projObj, id) => {
+ const state = store.getState();
+ if (state.proj.id !== id) {
+ store.dispatch(changeProjection(id, config));
+ }
+ });
let queryString = '';
history.listen((location, action) => {
diff --git a/web/js/projection/model.js b/web/js/projection/model.js
index e75658665..b66dff1c9 100644
--- a/web/js/projection/model.js
+++ b/web/js/projection/model.js
@@ -31,7 +31,7 @@ export function projectionModel(config) {
var updated = false;
if (!self.selected || self.selected.id !== id) {
self.selected = proj;
- self.events.trigger('select', proj);
+ self.events.trigger('select', proj, id);
}
return updated;
};