Skip to content

Commit

Permalink
fix: reset projection result to initial state to handle unchanged loc…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
friedjoff committed Jun 15, 2020
1 parent d3e8df9 commit 8287c0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/components/ProjectionResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ function ProjectionResult() {
const form = projectionResult.form.projections.slice(-1)[0] || {};
panes.push(getPane('today', location, i18n.language, t));
panes.push(getPane('form', form, i18n.language, t));
} else if (
projectionResult.moderate.projections ||
projectionResult.extreme.projections
) {
} else {
const moderateLoc = projectionResult.moderate.projections
? projectionResult.moderate.projections.slice(-1)[0] || {}
: {};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Recommendation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Recommendation({ sameAltitudinalZone }) {
let result;

if (projectionMode === 'f') {
projections = projectionResult.form.projections.slice(-1) || [];
projections = projectionResult.form.projections?.slice(-1) || [];
} else {
const { moderate, extreme } = projectionResult;
projections = [
Expand Down
3 changes: 2 additions & 1 deletion src/store/enhancers/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
setLocationResult,
setProjectionResult,
} from '../actions';
import { initialState } from '../reducers';

const projectionActionTypes = [
SET_FORM_LOCATION,
Expand Down Expand Up @@ -57,7 +58,7 @@ const projection = (store) => (next) => (action) => {
}

try {
const projectionResult = { extreme: {}, moderate: {}, form: {} };
const projectionResult = { ...initialState.projectionResult };
if (projectionMode === 'm') {
const {
targetAltitudinalZoneModerate: targetAZModerate,
Expand Down

0 comments on commit 8287c0f

Please sign in to comment.