Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
2205228cde |
4 changed files with 18 additions and 20 deletions
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<Modal isOpen contentLabel={__('Confirm File Remove')} type="card" onAborted={closeModal}>
|
||||
<Card
|
||||
|
@ -68,12 +72,12 @@ function ModalRemoveFile(props: Props) {
|
|||
checked={abandonChecked}
|
||||
onChange={() => setAbandonChecked(!abandonChecked)}
|
||||
/>
|
||||
{abandonChecked === true && (
|
||||
{abandonChecked && (
|
||||
<p className="help error__text">{__('This action is permanent and cannot be undone')}</p>
|
||||
)}
|
||||
|
||||
{/* @if TARGET='app' */}
|
||||
{abandonChecked === false && deleteChecked && (
|
||||
{!abandonChecked && deleteChecked && (
|
||||
<p className="help">{__('This file will be removed from your Library and Downloads folder.')}</p>
|
||||
)}
|
||||
{!deleteChecked && (
|
||||
|
@ -92,8 +96,8 @@ function ModalRemoveFile(props: Props) {
|
|||
<Button
|
||||
button="primary"
|
||||
label={isAbandoning ? __('Removing...') : __('OK')}
|
||||
disabled={isAbandoning || !(deleteChecked || abandonChecked)}
|
||||
onClick={() => deleteFile(uri, deleteChecked, claimIsMine ? abandonChecked : false, doGoBack)}
|
||||
disabled={disabled}
|
||||
onClick={() => deleteFile(uri, deleteChecked, claimIsMine ? abandonChecked : false)}
|
||||
/>
|
||||
<Button button="link" label={__('Cancel')} onClick={closeModal} />
|
||||
</div>
|
||||
|
|
|
@ -53,7 +53,7 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim, cb) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim, doGoBack) {
|
||||
export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim, doGoBack = true) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const playingUri = selectPlayingUri(state);
|
||||
|
@ -62,21 +62,15 @@ export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim
|
|||
const claimOutpoint = `${txid}:${nout}`;
|
||||
const actions = [];
|
||||
|
||||
if (!abandonClaim) {
|
||||
actions.push(doHideModal());
|
||||
}
|
||||
|
||||
actions.push(
|
||||
doDeleteFile(outpoint || claimOutpoint, deleteFromComputer, abandonClaim, (abandonState) => {
|
||||
if (abandonState === ABANDON_STATES.DONE) {
|
||||
if (abandonClaim) {
|
||||
if (doGoBack) {
|
||||
dispatch(goBack());
|
||||
}
|
||||
dispatch(doHideModal());
|
||||
}
|
||||
}
|
||||
})
|
||||
}),
|
||||
doHideModal(),
|
||||
);
|
||||
|
||||
if (playingUri && playingUri.uri === uri) {
|
||||
|
|
Loading…
Reference in a new issue