From 2205228cde338bb955e2c0ac3116c351ad51a748 Mon Sep 17 00:00:00 2001 From: saltrafael Date: Mon, 26 Jul 2021 11:19:09 -0300 Subject: [PATCH] Improve file deletion proccess and redirection --- ui/component/claimMenuList/view.jsx | 2 +- ui/modal/modalRemoveFile/index.js | 4 ++-- ui/modal/modalRemoveFile/view.jsx | 16 ++++++++++------ ui/redux/actions/file.js | 16 +++++----------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ui/component/claimMenuList/view.jsx b/ui/component/claimMenuList/view.jsx index 66535b73d..f1ff571b2 100644 --- a/ui/component/claimMenuList/view.jsx +++ b/ui/component/claimMenuList/view.jsx @@ -189,7 +189,7 @@ function ClaimMenuList(props: Props) { if (!repostedClaim && !isChannel) { openModal(MODALS.CONFIRM_FILE_REMOVE, { uri, doGoBack: false }); } else { - openModal(MODALS.CONFIRM_CLAIM_REVOKE, { claim, cb: isChannel && (() => replace(`/$/${PAGES.CHANNELS}`)) }); + openModal(MODALS.CONFIRM_CLAIM_REVOKE, { claim }); } } diff --git a/ui/modal/modalRemoveFile/index.js b/ui/modal/modalRemoveFile/index.js index 9d8dbfb9c..75ba42601 100644 --- a/ui/modal/modalRemoveFile/index.js +++ b/ui/modal/modalRemoveFile/index.js @@ -20,8 +20,8 @@ const select = (state, props) => ({ const perform = dispatch => ({ closeModal: () => dispatch(doHideModal()), doResolveUri: (uri) => dispatch(doResolveUri(uri)), - deleteFile: (uri, deleteFromComputer, abandonClaim, doGoBack) => { - dispatch(doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim, doGoBack)); + deleteFile: (uri, deleteFromComputer, abandonClaim) => { + dispatch(doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim, false)); }, }); diff --git a/ui/modal/modalRemoveFile/view.jsx b/ui/modal/modalRemoveFile/view.jsx index c95a2b77e..426fb204c 100644 --- a/ui/modal/modalRemoveFile/view.jsx +++ b/ui/modal/modalRemoveFile/view.jsx @@ -15,7 +15,6 @@ type Props = { doResolveUri: (string) => void, closeModal: () => void, deleteFile: (string, boolean, boolean, boolean) => void, - doGoBack: boolean, title: string, fileInfo?: { outpoint: ?string, @@ -24,7 +23,7 @@ type Props = { }; function ModalRemoveFile(props: Props) { - const { uri, claimIsMine, doResolveUri, closeModal, deleteFile, doGoBack = true, title, claim, isAbandoning } = props; + const { uri, claimIsMine, doResolveUri, closeModal, deleteFile, title, claim, isAbandoning } = props; const [deleteChecked, setDeleteChecked] = usePersistedState('modal-remove-file:delete', true); const [abandonChecked, setAbandonChecked] = usePersistedState('modal-remove-file:abandon', true); @@ -34,6 +33,11 @@ function ModalRemoveFile(props: Props) { } }, [uri, doResolveUri]); + let disabled = isAbandoning || !(deleteChecked || abandonChecked); + // @if TARGET='web' + disabled = isAbandoning || !abandonChecked; + // @endif + return ( setAbandonChecked(!abandonChecked)} /> - {abandonChecked === true && ( + {abandonChecked && (

{__('This action is permanent and cannot be undone')}

)} {/* @if TARGET='app' */} - {abandonChecked === false && deleteChecked && ( + {!abandonChecked && deleteChecked && (

{__('This file will be removed from your Library and Downloads folder.')}

)} {!deleteChecked && ( @@ -92,8 +96,8 @@ function ModalRemoveFile(props: Props) {