From a8570bdb22d81fbf18139c2f0b77cc85c4b4fcaa Mon Sep 17 00:00:00 2001 From: Daniel Shiffman Date: Wed, 18 Jan 2017 16:48:16 -0500 Subject: [PATCH] send user to empty sketch after deleting open sketch #175 (#270) --- client/modules/IDE/actions/projects.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/modules/IDE/actions/projects.js b/client/modules/IDE/actions/projects.js index 43892453..fc6bfd91 100644 --- a/client/modules/IDE/actions/projects.js +++ b/client/modules/IDE/actions/projects.js @@ -1,5 +1,7 @@ import * as ActionTypes from '../../../constants'; import axios from 'axios'; +import { setPreviousPath } from './ide'; +import { resetProject } from './project'; import { showAuthenticationError } from './ide'; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; @@ -27,9 +29,14 @@ export function getProjects(username) { } export function deleteProject(id) { - return (dispatch) => { + return (dispatch, getState) => { axios.delete(`${ROOT_URL}/projects/${id}`, { withCredentials: true }) .then(() => { + const state = getState(); + if (id === state.project.id) { + dispatch(resetProject()); + dispatch(setPreviousPath('/')); + } dispatch({ type: ActionTypes.DELETE_PROJECT, id