callback for abandons
This commit is contained in:
parent
1e505184dc
commit
cd3fa33066
4 changed files with 27 additions and 3 deletions
17
dist/bundle.es.js
vendored
17
dist/bundle.es.js
vendored
|
@ -757,6 +757,18 @@ var transaction_list = /*#__PURE__*/Object.freeze({
|
||||||
LATEST_PAGE_SIZE: LATEST_PAGE_SIZE
|
LATEST_PAGE_SIZE: LATEST_PAGE_SIZE
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const PENDING = 'pending';
|
||||||
|
const DONE = 'done';
|
||||||
|
const READY$1 = 'ready';
|
||||||
|
const ERROR = 'error';
|
||||||
|
|
||||||
|
var abandon_txo_states = /*#__PURE__*/Object.freeze({
|
||||||
|
PENDING: PENDING,
|
||||||
|
DONE: DONE,
|
||||||
|
READY: READY$1,
|
||||||
|
ERROR: ERROR
|
||||||
|
});
|
||||||
|
|
||||||
const ACTIVE = 'active'; // spent, active, all
|
const ACTIVE = 'active'; // spent, active, all
|
||||||
const TYPE = 'type'; // all, payment, support, channel, stream, repost
|
const TYPE = 'type'; // all, payment, support, channel, stream, repost
|
||||||
const SUB_TYPE = 'subtype'; // other, purchase, tip
|
const SUB_TYPE = 'subtype'; // other, purchase, tip
|
||||||
|
@ -3202,6 +3214,7 @@ function doFetchClaimListMine(page = 1, pageSize = 99999, resolve = true) {
|
||||||
|
|
||||||
function doAbandonTxo(txo, cb) {
|
function doAbandonTxo(txo, cb) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
|
if (cb) cb(PENDING);
|
||||||
const isClaim = txo.type === 'claim';
|
const isClaim = txo.type === 'claim';
|
||||||
const isSupport = txo.type === 'support' && txo.is_my_input === true;
|
const isSupport = txo.type === 'support' && txo.is_my_input === true;
|
||||||
const isTip = txo.type === 'support' && txo.is_my_input === false;
|
const isTip = txo.type === 'support' && txo.is_my_input === false;
|
||||||
|
@ -3217,6 +3230,7 @@ function doAbandonTxo(txo, cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const errorCallback = () => {
|
const errorCallback = () => {
|
||||||
|
if (cb) cb(ERROR);
|
||||||
dispatch(doToast({
|
dispatch(doToast({
|
||||||
message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip',
|
message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip',
|
||||||
isError: true
|
isError: true
|
||||||
|
@ -3237,7 +3251,7 @@ function doAbandonTxo(txo, cb) {
|
||||||
} else {
|
} else {
|
||||||
abandonMessage = 'Successfully unlocked your tip!';
|
abandonMessage = 'Successfully unlocked your tip!';
|
||||||
}
|
}
|
||||||
if (cb) cb();
|
if (cb) cb(DONE);
|
||||||
|
|
||||||
dispatch(doToast({
|
dispatch(doToast({
|
||||||
message: abandonMessage
|
message: abandonMessage
|
||||||
|
@ -6565,6 +6579,7 @@ exports.SORT_OPTIONS = sort_options;
|
||||||
exports.SPEECH_URLS = speech_urls;
|
exports.SPEECH_URLS = speech_urls;
|
||||||
exports.THUMBNAIL_STATUSES = thumbnail_upload_statuses;
|
exports.THUMBNAIL_STATUSES = thumbnail_upload_statuses;
|
||||||
exports.TRANSACTIONS = transaction_types;
|
exports.TRANSACTIONS = transaction_types;
|
||||||
|
exports.TXO_ABANDON_STATES = abandon_txo_states;
|
||||||
exports.TXO_LIST = txo_list;
|
exports.TXO_LIST = txo_list;
|
||||||
exports.TX_LIST = transaction_list;
|
exports.TX_LIST = transaction_list;
|
||||||
exports.apiCall = apiCall;
|
exports.apiCall = apiCall;
|
||||||
|
|
4
src/constants/abandon_txo_states.js
Normal file
4
src/constants/abandon_txo_states.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export const PENDING = 'pending';
|
||||||
|
export const DONE = 'done';
|
||||||
|
export const READY = 'ready';
|
||||||
|
export const ERROR = 'error';
|
|
@ -7,6 +7,7 @@ import * as SORT_OPTIONS from 'constants/sort_options';
|
||||||
import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses';
|
import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses';
|
||||||
import * as TRANSACTIONS from 'constants/transaction_types';
|
import * as TRANSACTIONS from 'constants/transaction_types';
|
||||||
import * as TX_LIST from 'constants/transaction_list';
|
import * as TX_LIST from 'constants/transaction_list';
|
||||||
|
import * as TXO_ABANDON_STATES from 'constants/abandon_txo_states';
|
||||||
import * as TXO_LIST from 'constants/txo_list';
|
import * as TXO_LIST from 'constants/txo_list';
|
||||||
import * as SPEECH_URLS from 'constants/speech_urls';
|
import * as SPEECH_URLS from 'constants/speech_urls';
|
||||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||||
|
@ -29,6 +30,7 @@ export {
|
||||||
TRANSACTIONS,
|
TRANSACTIONS,
|
||||||
TX_LIST,
|
TX_LIST,
|
||||||
TXO_LIST,
|
TXO_LIST,
|
||||||
|
TXO_ABANDON_STATES,
|
||||||
SORT_OPTIONS,
|
SORT_OPTIONS,
|
||||||
PAGES,
|
PAGES,
|
||||||
DEFAULT_KNOWN_TAGS,
|
DEFAULT_KNOWN_TAGS,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as ACTIONS from 'constants/action_types';
|
import * as ACTIONS from 'constants/action_types';
|
||||||
|
import * as TXO_STATES from 'constants/abandon_txo_states';
|
||||||
import Lbry from 'lbry';
|
import Lbry from 'lbry';
|
||||||
import { normalizeURI } from 'lbryURI';
|
import { normalizeURI } from 'lbryURI';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
|
@ -120,8 +121,9 @@ export function doFetchClaimListMine(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doAbandonTxo(txo: Txo, cb: any => void) {
|
export function doAbandonTxo(txo: Txo, cb: string => void) {
|
||||||
return (dispatch: Dispatch) => {
|
return (dispatch: Dispatch) => {
|
||||||
|
if (cb) cb(TXO_STATES.PENDING);
|
||||||
const isClaim = txo.type === 'claim';
|
const isClaim = txo.type === 'claim';
|
||||||
const isSupport = txo.type === 'support' && txo.is_my_input === true;
|
const isSupport = txo.type === 'support' && txo.is_my_input === true;
|
||||||
const isTip = txo.type === 'support' && txo.is_my_input === false;
|
const isTip = txo.type === 'support' && txo.is_my_input === false;
|
||||||
|
@ -141,6 +143,7 @@ export function doAbandonTxo(txo: Txo, cb: any => void) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const errorCallback = () => {
|
const errorCallback = () => {
|
||||||
|
if (cb) cb(TXO_STATES.ERROR);
|
||||||
dispatch(
|
dispatch(
|
||||||
doToast({
|
doToast({
|
||||||
message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip',
|
message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip',
|
||||||
|
@ -163,7 +166,7 @@ export function doAbandonTxo(txo: Txo, cb: any => void) {
|
||||||
} else {
|
} else {
|
||||||
abandonMessage = 'Successfully unlocked your tip!';
|
abandonMessage = 'Successfully unlocked your tip!';
|
||||||
}
|
}
|
||||||
if (cb) cb();
|
if (cb) cb(TXO_STATES.DONE);
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
doToast({
|
doToast({
|
||||||
|
|
Loading…
Add table
Reference in a new issue