diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 0b3c8f9..c81f072 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -757,6 +757,18 @@ var transaction_list = /*#__PURE__*/Object.freeze({ 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 TYPE = 'type'; // all, payment, support, channel, stream, repost const SUB_TYPE = 'subtype'; // other, purchase, tip @@ -3202,6 +3214,7 @@ function doFetchClaimListMine(page = 1, pageSize = 99999, resolve = true) { function doAbandonTxo(txo, cb) { return dispatch => { + if (cb) cb(PENDING); const isClaim = txo.type === 'claim'; const isSupport = txo.type === 'support' && txo.is_my_input === true; const isTip = txo.type === 'support' && txo.is_my_input === false; @@ -3217,6 +3230,7 @@ function doAbandonTxo(txo, cb) { }); const errorCallback = () => { + if (cb) cb(ERROR); dispatch(doToast({ message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip', isError: true @@ -3237,7 +3251,7 @@ function doAbandonTxo(txo, cb) { } else { abandonMessage = 'Successfully unlocked your tip!'; } - if (cb) cb(); + if (cb) cb(DONE); dispatch(doToast({ message: abandonMessage @@ -6565,6 +6579,7 @@ exports.SORT_OPTIONS = sort_options; exports.SPEECH_URLS = speech_urls; exports.THUMBNAIL_STATUSES = thumbnail_upload_statuses; exports.TRANSACTIONS = transaction_types; +exports.TXO_ABANDON_STATES = abandon_txo_states; exports.TXO_LIST = txo_list; exports.TX_LIST = transaction_list; exports.apiCall = apiCall; diff --git a/src/constants/abandon_txo_states.js b/src/constants/abandon_txo_states.js new file mode 100644 index 0000000..3761c9e --- /dev/null +++ b/src/constants/abandon_txo_states.js @@ -0,0 +1,4 @@ +export const PENDING = 'pending'; +export const DONE = 'done'; +export const READY = 'ready'; +export const ERROR = 'error'; diff --git a/src/index.js b/src/index.js index ac96c7c..e41bdf7 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,7 @@ import * as SORT_OPTIONS from 'constants/sort_options'; import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses'; import * as TRANSACTIONS from 'constants/transaction_types'; 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 SPEECH_URLS from 'constants/speech_urls'; import * as DAEMON_SETTINGS from 'constants/daemon_settings'; @@ -29,6 +30,7 @@ export { TRANSACTIONS, TX_LIST, TXO_LIST, + TXO_ABANDON_STATES, SORT_OPTIONS, PAGES, DEFAULT_KNOWN_TAGS, diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 5a1e45f..234e211 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -1,5 +1,6 @@ // @flow import * as ACTIONS from 'constants/action_types'; +import * as TXO_STATES from 'constants/abandon_txo_states'; import Lbry from 'lbry'; import { normalizeURI } from 'lbryURI'; 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) => { + if (cb) cb(TXO_STATES.PENDING); const isClaim = txo.type === 'claim'; const isSupport = txo.type === 'support' && txo.is_my_input === true; const isTip = txo.type === 'support' && txo.is_my_input === false; @@ -141,6 +143,7 @@ export function doAbandonTxo(txo: Txo, cb: any => void) { }); const errorCallback = () => { + if (cb) cb(TXO_STATES.ERROR); dispatch( doToast({ message: isClaim ? 'Error abandoning your claim/support' : 'Error unlocking your tip', @@ -163,7 +166,7 @@ export function doAbandonTxo(txo: Txo, cb: any => void) { } else { abandonMessage = 'Successfully unlocked your tip!'; } - if (cb) cb(); + if (cb) cb(TXO_STATES.DONE); dispatch( doToast({