diff --git a/ui/js/actions/file_info.js b/ui/js/actions/file_info.js index d21df8d2a..9ed2df5a7 100644 --- a/ui/js/actions/file_info.js +++ b/ui/js/actions/file_info.js @@ -10,8 +10,11 @@ import { selectIsFetchingFileList, selectFileInfosByOutpoint, selectUrisLoading, + selectTotalDownloadProgress, } from "selectors/file_info"; -import { doCloseModal } from "actions/app"; +import { doCloseModal, doHistoryBack } from "actions/app"; +import setProgressBar from "util/setProgressBar"; +import batchActions from "util/batchActions"; const { shell } = require("electron"); @@ -119,7 +122,22 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) { }, }); - dispatch(doCloseModal()); + const totalProgress = selectTotalDownloadProgress(getState()); + setProgressBar(totalProgress); + }; +} + +export function doDeleteFileAndGoBack( + fileInfo, + deleteFromComputer, + abandonClaim +) { + return function(dispatch, getState) { + const actions = []; + actions.push(doCloseModal()); + actions.push(doHistoryBack()); + actions.push(doDeleteFile(fileInfo, deleteFromComputer, abandonClaim)); + dispatch(batchActions(...actions)); }; } diff --git a/ui/js/component/modalRemoveFile/index.js b/ui/js/component/modalRemoveFile/index.js index de54514d5..211bdff26 100644 --- a/ui/js/component/modalRemoveFile/index.js +++ b/ui/js/component/modalRemoveFile/index.js @@ -1,8 +1,9 @@ import React from "react"; import { connect } from "react-redux"; import { doCloseModal, doHistoryBack } from "actions/app"; -import { doDeleteFile } from "actions/file_info"; +import { doDeleteFileAndGoBack } from "actions/file_info"; import { makeSelectClaimForUriIsMine } from "selectors/claims"; +import batchActions from "util/batchActions"; import ModalRemoveFile from "./view"; @@ -19,8 +20,7 @@ const makeSelect = () => { const perform = dispatch => ({ closeModal: () => dispatch(doCloseModal()), deleteFile: (fileInfo, deleteFromComputer, abandonClaim) => { - dispatch(doHistoryBack()); - dispatch(doDeleteFile(fileInfo, deleteFromComputer, abandonClaim)); + dispatch(doDeleteFileAndGoBack(fileInfo, deleteFromComputer, abandonClaim)); }, }); diff --git a/ui/js/reducers/file_info.js b/ui/js/reducers/file_info.js index 33655aca5..cb5221c98 100644 --- a/ui/js/reducers/file_info.js +++ b/ui/js/reducers/file_info.js @@ -106,11 +106,14 @@ reducers[types.FILE_DELETE] = function(state, action) { const { outpoint } = action.data; const newByOutpoint = Object.assign({}, state.byOutpoint); + const downloadingByOutpoint = Object.assign({}, state.downloadingByOutpoint); delete newByOutpoint[outpoint]; + delete downloadingByOutpoint[outpoint]; return Object.assign({}, state, { byOutpoint: newByOutpoint, + downloadingByOutpoint, }); };