lbry-desktop/ui/redux/actions/coinSwap.js

40 lines
972 B
JavaScript
Raw Normal View History

2021-03-25 12:24:49 +01:00
// @flow
import * as ACTIONS from 'constants/action_types';
import { selectPrefsReady } from 'redux/selectors/sync';
import { doAlertWaitingForSync } from 'redux/actions/app';
export const doAddCoinSwap = (coinSwap: CoinSwapInfo) => (dispatch: Dispatch, getState: GetState) => {
2021-03-25 12:24:49 +01:00
const state = getState();
const ready = selectPrefsReady(state);
if (!ready) {
return dispatch(doAlertWaitingForSync());
}
dispatch({
type: ACTIONS.ADD_COIN_SWAP,
2021-03-25 12:24:49 +01:00
data: {
coin: coinSwap.coin,
sendAddress: coinSwap.sendAddress,
sendAmount: coinSwap.sendAmount,
lbcAmount: coinSwap.lbcAmount,
2021-03-25 12:24:49 +01:00
},
});
};
export const doRemoveCoinSwap = (sendAddress: string) => (dispatch: Dispatch, getState: GetState) => {
2021-03-25 12:24:49 +01:00
const state = getState();
const ready = selectPrefsReady(state);
if (!ready) {
return dispatch(doAlertWaitingForSync());
}
dispatch({
type: ACTIONS.REMOVE_COIN_SWAP,
2021-03-25 12:24:49 +01:00
data: {
sendAddress,
2021-03-25 12:24:49 +01:00
},
});
};