wait to go back until claim has been abandoned
This commit is contained in:
parent
1ad430f463
commit
0f51cf8986
1 changed files with 25 additions and 8 deletions
|
@ -2,7 +2,14 @@ import * as ACTIONS from 'constants/action_types';
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
import { shell } from 'electron';
|
import { shell } from 'electron';
|
||||||
// @endif
|
// @endif
|
||||||
import { Lbry, batchActions, doAbandonClaim, makeSelectFileInfoForUri, makeSelectClaimForUri } from 'lbry-redux';
|
import {
|
||||||
|
Lbry,
|
||||||
|
batchActions,
|
||||||
|
doAbandonClaim,
|
||||||
|
makeSelectFileInfoForUri,
|
||||||
|
makeSelectClaimForUri,
|
||||||
|
ABANDON_STATES,
|
||||||
|
} from 'lbry-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import { goBack } from 'connected-react-router';
|
import { goBack } from 'connected-react-router';
|
||||||
import { doSetPlayingUri } from 'redux/actions/content';
|
import { doSetPlayingUri } from 'redux/actions/content';
|
||||||
|
@ -23,11 +30,11 @@ export function doOpenFileInShell(path) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) {
|
export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim, cb) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
if (abandonClaim) {
|
if (abandonClaim) {
|
||||||
const [txid, nout] = outpoint.split(':');
|
const [txid, nout] = outpoint.split(':');
|
||||||
dispatch(doAbandonClaim(txid, Number(nout)));
|
dispatch(doAbandonClaim(txid, Number(nout), cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
|
@ -54,8 +61,21 @@ export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim
|
||||||
const { nout, txid } = makeSelectClaimForUri(uri)(state);
|
const { nout, txid } = makeSelectClaimForUri(uri)(state);
|
||||||
const claimOutpoint = `${txid}:${nout}`;
|
const claimOutpoint = `${txid}:${nout}`;
|
||||||
const actions = [];
|
const actions = [];
|
||||||
actions.push(doHideModal());
|
|
||||||
actions.push(doDeleteFile(outpoint || claimOutpoint, deleteFromComputer, abandonClaim));
|
if (!abandonClaim) {
|
||||||
|
actions.push(doHideModal());
|
||||||
|
}
|
||||||
|
|
||||||
|
actions.push(
|
||||||
|
doDeleteFile(outpoint || claimOutpoint, deleteFromComputer, abandonClaim, abandonState => {
|
||||||
|
if (abandonState === ABANDON_STATES.DONE) {
|
||||||
|
if (abandonClaim) {
|
||||||
|
dispatch(goBack());
|
||||||
|
dispatch(doHideModal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
if (playingUri === uri) {
|
if (playingUri === uri) {
|
||||||
actions.push(doSetPlayingUri(null));
|
actions.push(doSetPlayingUri(null));
|
||||||
|
@ -64,8 +84,5 @@ export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim
|
||||||
// we need to alter autoplay to not start downloading again after you delete it
|
// we need to alter autoplay to not start downloading again after you delete it
|
||||||
|
|
||||||
dispatch(batchActions(...actions));
|
dispatch(batchActions(...actions));
|
||||||
if (abandonClaim) {
|
|
||||||
dispatch(goBack());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue