signed support functionality #322
2 changed files with 211 additions and 209 deletions
307
dist/bundle.es.js
vendored
307
dist/bundle.es.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,11 @@
|
|||
import * as ACTIONS from 'constants/action_types';
|
||||
import Lbry from 'lbry';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { selectBalance, selectPendingSupportTransactions, selectTxoPageParams } from 'redux/selectors/wallet';
|
||||
import {
|
||||
selectBalance,
|
||||
selectPendingSupportTransactions,
|
||||
selectTxoPageParams,
|
||||
} from 'redux/selectors/wallet';
|
||||
import { creditsToString } from 'util/format-credits';
|
||||
import { selectMyClaimsRaw } from 'redux/selectors/claims';
|
||||
import { doFetchChannelListMine, doFetchClaimListMine } from 'redux/actions/claims';
|
||||
|
@ -98,7 +102,7 @@ export function doFetchTxoPage() {
|
|||
};
|
||||
}
|
||||
|
||||
export function doUpdateTxoPageParams(params: TxoListParams) {
|
||||
export function doUpdateTxoPageParams(params) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.UPDATE_TXO_FETCH_PARAMS,
|
||||
|
@ -236,16 +240,16 @@ export function doSetDraftTransactionAddress(address) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doSendTip(amount, claimId, isSupport, successCallback, errorCallback) {
|
||||
export function doSendTip(params, isSupport, successCallback, errorCallback) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const balance = selectBalance(state);
|
||||
const myClaims = selectMyClaimsRaw(state);
|
||||
|
||||
const shouldSupport =
|
||||
isSupport || (myClaims ? myClaims.find(claim => claim.claim_id === claimId) : false);
|
||||
isSupport || (myClaims ? myClaims.find(claim => claim.claim_id === params.claim_id) : false);
|
||||
|
||||
if (balance - amount <= 0) {
|
||||
if (balance - params.amount <= 0) {
|
||||
dispatch(
|
||||
doToast({
|
||||
message: __('Insufficient credits'),
|
||||
|
@ -259,8 +263,8 @@ export function doSendTip(amount, claimId, isSupport, successCallback, errorCall
|
|||
dispatch(
|
||||
doToast({
|
||||
message: shouldSupport
|
||||
? __('You deposited %amount% LBC as a support!', { amount })
|
||||
: __('You sent %amount% LBC as a tip, Mahalo!', { amount }),
|
||||
? __('You deposited %amount% LBC as a support!', { amount: params.amount })
|
||||
: __('You sent %amount% LBC as a tip, Mahalo!', { amount: params.amount }),
|
||||
linkText: __('History'),
|
||||
linkTarget: __('/wallet'),
|
||||
})
|
||||
|
@ -300,10 +304,10 @@ export function doSendTip(amount, claimId, isSupport, successCallback, errorCall
|
|||
});
|
||||
|
||||
Lbry.support_create({
|
||||
claim_id: claimId,
|
||||
amount: creditsToString(amount),
|
||||
...params,
|
||||
tip: !shouldSupport,
|
||||
blocking: true,
|
||||
amount: creditsToString(params.amount),
|
||||
}).then(success, error);
|
||||
};
|
||||
}
|
||||
|
@ -395,9 +399,8 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) {
|
|||
const params = { claim_id: claimId };
|
||||
if (preview) params['preview'] = true;
|
||||
if (keep) params['keep'] = keep;
|
||||
return (
|
||||
Lbry.support_abandon(params)
|
||||
.then((res) => {
|
||||
return Lbry.support_abandon(params)
|
||||
.then(res => {
|
||||
if (!preview) {
|
||||
dispatch({
|
||||
type: ACTIONS.ABANDON_CLAIM_SUPPORT_COMPLETED,
|
||||
|
@ -412,7 +415,7 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) {
|
|||
type: ACTIONS.ABANDON_CLAIM_SUPPORT_FAILED,
|
||||
data: e.message,
|
||||
});
|
||||
}));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -469,7 +472,6 @@ export function doWalletStatus() {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
export function doSetTransactionListFilter(filterOption) {
|
||||
return {
|
||||
type: ACTIONS.SET_TRANSACTION_LIST_FILTER,
|
||||
|
@ -490,10 +492,7 @@ export function doUpdateBlockHeight() {
|
|||
}
|
||||
|
||||
// Calls transaction_show on txes until any pending txes are confirmed
|
||||
export const doCheckPendingTxs = () => (
|
||||
dispatch,
|
||||
getState
|
||||
) => {
|
||||
export const doCheckPendingTxs = () => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const pendingTxsById = selectPendingSupportTransactions(state); // {}
|
||||
if (!Object.keys(pendingTxsById).length) {
|
||||
|
@ -512,17 +511,19 @@ export const doCheckPendingTxs = () => (
|
|||
types.add(data.type);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(txShows => {
|
||||
Promise.all(promises)
|
||||
.then(txShows => {
|
||||
txShows.forEach(result => {
|
||||
if (result.height <= 0) {
|
||||
const entries = Object.entries(pendingTxs);
|
||||
const match = entries.find((entry) => entry[1].txid === result.txid);
|
||||
const match = entries.find(entry => entry[1].txid === result.txid);
|
||||
newPendingTxes[match[0]] = match[1];
|
||||
} else {
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
}).then(() => {
|
||||
})
|
||||
.then(() => {
|
||||
if (changed) {
|
||||
dispatch({
|
||||
type: ACTIONS.PENDING_SUPPORTS_UPDATED,
|
||||
|
|
Loading…
Reference in a new issue