Merge pull request #96 from lbryio/claim-abandon
fix: check for sucessful abaondon and add toast on success
This commit is contained in:
commit
cedf942f4d
2 changed files with 37 additions and 25 deletions
15
dist/bundle.js
vendored
15
dist/bundle.js
vendored
|
@ -1925,28 +1925,33 @@ function doAbandonClaim(txid, nout) {
|
||||||
var errorCallback = function errorCallback() {
|
var errorCallback = function errorCallback() {
|
||||||
dispatch((0, _notifications.doNotify)({
|
dispatch((0, _notifications.doNotify)({
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Error abandoning claim',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast']
|
displayType: ['snackbar', 'toast']
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
var successCallback = function successCallback(results) {
|
var successCallback = function successCallback(results) {
|
||||||
if (results.txid) {
|
if (results.success === true) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.ABANDON_CLAIM_SUCCEEDED,
|
type: ACTIONS.ABANDON_CLAIM_SUCCEEDED,
|
||||||
data: {
|
data: {
|
||||||
claimId: claimId
|
claimId: claimId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dispatch((0, _notifications.doNotify)({
|
||||||
|
title: 'Transaction successful',
|
||||||
|
message: 'Successfully abandoned your claim',
|
||||||
|
displayType: ['snackbar', 'toast']
|
||||||
|
}));
|
||||||
dispatch(doResolveUri((0, _lbryURI.buildURI)({ name: name, claimId: claimId })));
|
dispatch(doResolveUri((0, _lbryURI.buildURI)({ name: name, claimId: claimId })));
|
||||||
dispatch(doFetchClaimListMine());
|
dispatch(doFetchClaimListMine());
|
||||||
} else {
|
} else {
|
||||||
dispatch((0, _notifications.doNotify)({
|
dispatch((0, _notifications.doNotify)({
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Error abandoning claim',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast']
|
displayType: ['snackbar', 'toast']
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ export function doResolveUris(uris) {
|
||||||
|
|
||||||
// Filter out URIs that are already resolving
|
// Filter out URIs that are already resolving
|
||||||
const resolvingUris = selectResolvingUris(state);
|
const resolvingUris = selectResolvingUris(state);
|
||||||
const urisToResolve = normalizedUris.filter(uri => !resolvingUris.includes(uri));
|
const urisToResolve = normalizedUris.filter((uri) => !resolvingUris.includes(uri));
|
||||||
|
|
||||||
if (urisToResolve.length === 0) {
|
if (urisToResolve.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@ export function doResolveUris(uris) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const resolveInfo = {};
|
const resolveInfo = {};
|
||||||
Lbry.resolve({ uris: urisToResolve }).then(result => {
|
Lbry.resolve({ uris: urisToResolve }).then((result) => {
|
||||||
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
const fallbackResolveInfo = {
|
const fallbackResolveInfo = {
|
||||||
claim: null,
|
claim: null,
|
||||||
|
@ -52,12 +52,12 @@ export function doResolveUri(uri) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchClaimListMine() {
|
export function doFetchClaimListMine() {
|
||||||
return dispatch => {
|
return (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbry.claim_list_mine().then(claims => {
|
Lbry.claim_list_mine().then((claims) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
|
@ -73,7 +73,7 @@ export function doAbandonClaim(txid, nout) {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const myClaims = selectMyClaimsRaw(state);
|
const myClaims = selectMyClaimsRaw(state);
|
||||||
const { claim_id: claimId, name } = myClaims.find(
|
const { claim_id: claimId, name } = myClaims.find(
|
||||||
claim => claim.txid === txid && claim.nout === nout
|
(claim) => claim.txid === txid && claim.nout === nout
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -87,30 +87,37 @@ export function doAbandonClaim(txid, nout) {
|
||||||
dispatch(
|
dispatch(
|
||||||
doNotify({
|
doNotify({
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Error abandoning claim',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast'],
|
displayType: ['snackbar', 'toast'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const successCallback = results => {
|
const successCallback = (results) => {
|
||||||
if (results.txid) {
|
if (results.success === true) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.ABANDON_CLAIM_SUCCEEDED,
|
type: ACTIONS.ABANDON_CLAIM_SUCCEEDED,
|
||||||
data: {
|
data: {
|
||||||
claimId,
|
claimId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
dispatch(
|
||||||
|
doNotify({
|
||||||
|
title: 'Transaction successful',
|
||||||
|
message: 'Successfully abandoned your claim',
|
||||||
|
displayType: ['snackbar', 'toast'],
|
||||||
|
})
|
||||||
|
);
|
||||||
dispatch(doResolveUri(buildURI({ name, claimId })));
|
dispatch(doResolveUri(buildURI({ name, claimId })));
|
||||||
dispatch(doFetchClaimListMine());
|
dispatch(doFetchClaimListMine());
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
doNotify({
|
doNotify({
|
||||||
title: 'Transaction failed',
|
title: 'Transaction failed',
|
||||||
message: 'Transaction failed',
|
message: 'Error abandoning claim',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
displayType: ['modal', 'toast'],
|
displayType: ['snackbar', 'toast'],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -124,14 +131,14 @@ export function doAbandonClaim(txid, nout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchFeaturedUris() {
|
export function doFetchFeaturedUris() {
|
||||||
return dispatch => {
|
return (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_STARTED,
|
type: ACTIONS.FETCH_FEATURED_CONTENT_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
const success = ({ Uris }) => {
|
const success = ({ Uris }) => {
|
||||||
let urisToResolve = [];
|
let urisToResolve = [];
|
||||||
Object.keys(Uris).forEach(category => {
|
Object.keys(Uris).forEach((category) => {
|
||||||
urisToResolve = [...urisToResolve, ...Uris[category]];
|
urisToResolve = [...urisToResolve, ...Uris[category]];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -162,13 +169,13 @@ export function doFetchFeaturedUris() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchTrendingUris() {
|
export function doFetchTrendingUris() {
|
||||||
return dispatch => {
|
return (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_TRENDING_CONTENT_STARTED,
|
type: ACTIONS.FETCH_TRENDING_CONTENT_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
const success = data => {
|
const success = (data) => {
|
||||||
const urisToResolve = data.map(uri => uri.url);
|
const urisToResolve = data.map((uri) => uri.url);
|
||||||
const actions = [
|
const actions = [
|
||||||
doResolveUris(urisToResolve),
|
doResolveUris(urisToResolve),
|
||||||
{
|
{
|
||||||
|
@ -196,13 +203,13 @@ export function doFetchTrendingUris() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchClaimsByChannel(uri, page) {
|
export function doFetchClaimsByChannel(uri, page) {
|
||||||
return dispatch => {
|
return (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED,
|
type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED,
|
||||||
data: { uri, page },
|
data: { uri, page },
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbry.claim_list_by_channel({ uri, page: page || 1 }).then(result => {
|
Lbry.claim_list_by_channel({ uri, page: page || 1 }).then((result) => {
|
||||||
const claimResult = result[uri] || {};
|
const claimResult = result[uri] || {};
|
||||||
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;
|
||||||
|
|
||||||
|
@ -219,13 +226,13 @@ export function doFetchClaimsByChannel(uri, page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchClaimCountByChannel(uri) {
|
export function doFetchClaimCountByChannel(uri) {
|
||||||
return dispatch => {
|
return (dispatch) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CHANNEL_CLAIM_COUNT_STARTED,
|
type: ACTIONS.FETCH_CHANNEL_CLAIM_COUNT_STARTED,
|
||||||
data: { uri },
|
data: { uri },
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbry.claim_list_by_channel({ uri }).then(result => {
|
Lbry.claim_list_by_channel({ uri }).then((result) => {
|
||||||
const claimResult = result[uri];
|
const claimResult = result[uri];
|
||||||
const totalClaims = claimResult ? claimResult.claims_in_channel : 0;
|
const totalClaims = claimResult ? claimResult.claims_in_channel : 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue