From d1ecb7b5980914cb2361ae75ceedd2ce881567af Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Wed, 20 Feb 2019 17:00:26 +0000 Subject: [PATCH] Gh-991: prevent showing message if not submission was ever active --- .../static_src/src/app/src/redux/actions/submissions.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opentech/static_src/src/app/src/redux/actions/submissions.js b/opentech/static_src/src/app/src/redux/actions/submissions.js index b1c4cabdc..f55cd9a36 100644 --- a/opentech/static_src/src/app/src/redux/actions/submissions.js +++ b/opentech/static_src/src/app/src/redux/actions/submissions.js @@ -82,7 +82,7 @@ export const loadSubmissionFromURL = () => (dispatch, getState) => { export const setCurrentSubmission = id => (dispatch, getState) => { const submissionID = getCurrentSubmissionID(getState()) - if (id && submissionID !== id) { + if (id !== null && submissionID !== id) { dispatch(push(`?submission=${id}`)); } else if (!id) { dispatch(push('?')); @@ -129,7 +129,8 @@ export const loadCurrentRoundSubmissions = () => (dispatch, getState) => { return dispatch(fetchSubmissionsByRound(getCurrentRoundID(state))).then(() => { const state = getState() const ids = getCurrentRoundSubmissionIDs(state) - if (!ids.includes(getCurrentSubmissionID(state))) { + const currentSubmissionID = getCurrentSubmissionID(state) + if (currentSubmissionID !== null && !ids.includes(currentSubmissionID)) { dispatch(addMessage('The selected submission is not available in this view', MESSAGE_TYPES.WARNING)) return dispatch(setCurrentSubmission(null)) } @@ -195,7 +196,8 @@ export const loadSubmissionsForCurrentStatus = () => (dispatch, getState) => { return dispatch(fetchSubmissionsByStatuses(getCurrentStatuses(state))).then(() => { const state = getState() const ids = getSubmissionIDsForCurrentStatuses(state) - if (!ids.includes(getCurrentSubmissionID(state))) { + const currentSubmissionID = getCurrentSubmissionID(state) + if (currentSubmissionID !== null && !ids.includes(currentSubmissionID)) { dispatch(addMessage('The selected submission is not available in this view', MESSAGE_TYPES.WARNING)) return dispatch(setCurrentSubmission(null)) } -- GitLab