channel modlist on confirm

This commit is contained in:
zeppi 2021-07-02 16:44:44 -04:00
parent d4d927ce7b
commit aae1688921
2 changed files with 28 additions and 16 deletions

20
dist/bundle.es.js vendored
View file

@ -3723,7 +3723,7 @@ var _extends$5 = Object.assign || function (target) { for (var i = 1; i < argume
function _asyncToGenerator$1(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _asyncToGenerator$1(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
let checkPendingCallbacks = []; let onChannelConfirmCallback;
let checkPendingInterval; let checkPendingInterval;
function doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) { function doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) {
@ -4064,7 +4064,7 @@ function doClearChannelErrors() {
}; };
} }
function doCreateChannel(name, amount, optionalParams, cb) { function doCreateChannel(name, amount, optionalParams, onConfirm) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: CREATE_CHANNEL_STARTED type: CREATE_CHANNEL_STARTED
@ -4118,7 +4118,7 @@ function doCreateChannel(name, amount, optionalParams, cb) {
claims: [channelClaim] claims: [channelClaim]
} }
}); });
dispatch(doCheckPendingClaims(cb)); dispatch(doCheckPendingClaims(onConfirm));
return channelClaim; return channelClaim;
}).catch(error => { }).catch(error => {
dispatch({ dispatch({
@ -4547,9 +4547,12 @@ function doPurchaseList(page = 1, pageSize = PAGE_SIZE) {
}; };
} }
const doCheckPendingClaims = onConfirmed => (dispatch, getState) => { const doCheckPendingClaims = onChannelConfirmed => (dispatch, getState) => {
if (onChannelConfirmed) {
onChannelConfirmCallback = onChannelConfirmed;
}
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
const checkTxoList = checkPendingCallbacks => { const checkTxoList = () => {
const state = getState(); const state = getState();
const pendingById = Object.assign({}, selectPendingClaimsById(state)); const pendingById = Object.assign({}, selectPendingClaimsById(state));
const pendingTxos = Object.values(pendingById).map(p => p.txid); const pendingTxos = Object.values(pendingById).map(p => p.txid);
@ -4584,7 +4587,10 @@ const doCheckPendingClaims = onConfirmed => (dispatch, getState) => {
collectionIds collectionIds
})); }));
} }
checkPendingCallbacks.forEach(cb => cb()); const channelClaims = claims.filter(claim => claim.value_type === 'channel');
if (channelClaims.length && onChannelConfirmCallback) {
channelClaims.forEach(claim => onChannelConfirmCallback(claim));
}
if (Object.keys(pendingById).length === 0) { if (Object.keys(pendingById).length === 0) {
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
} }
@ -4597,7 +4603,7 @@ const doCheckPendingClaims = onConfirmed => (dispatch, getState) => {
}; };
// do something with onConfirmed (typically get blocklist for channel) // do something with onConfirmed (typically get blocklist for channel)
checkPendingInterval = setInterval(() => { checkPendingInterval = setInterval(() => {
checkTxoList(checkPendingCallbacks); checkTxoList();
}, 30000); }, 30000);
}; };

View file

@ -26,7 +26,7 @@ import {
doCollectionDelete, doCollectionDelete,
} from 'redux/actions/collections'; } from 'redux/actions/collections';
let checkPendingCallbacks = []; let onChannelConfirmCallback;
let checkPendingInterval; let checkPendingInterval;
export function doResolveUris( export function doResolveUris(
@ -76,7 +76,7 @@ export function doResolveUris(
const collectionIds: Array<string> = []; const collectionIds: Array<string> = [];
return Lbry.resolve({ urls: urisToResolve, ...options }).then( return Lbry.resolve({ urls: urisToResolve, ...options }).then(
async (result: ResolveResponse) => { async(result: ResolveResponse) => {
let repostedResults = {}; let repostedResults = {};
const repostsToResolve = []; const repostsToResolve = [];
const fallbackResolveInfo = { const fallbackResolveInfo = {
@ -404,7 +404,7 @@ export function doClearChannelErrors() {
}; };
} }
export function doCreateChannel(name: string, amount: number, optionalParams: any, cb: any) { export function doCreateChannel(name: string, amount: number, optionalParams: any, onConfirm: any) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.CREATE_CHANNEL_STARTED, type: ACTIONS.CREATE_CHANNEL_STARTED,
@ -471,7 +471,7 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
claims: [channelClaim], claims: [channelClaim],
}, },
}); });
dispatch(doCheckPendingClaims(cb)); dispatch(doCheckPendingClaims(onConfirm));
return channelClaim; return channelClaim;
}) })
.catch(error => { .catch(error => {
@ -648,7 +648,7 @@ export function doClaimSearch(
} }
) { ) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);
return async (dispatch: Dispatch) => { return async(dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.CLAIM_SEARCH_STARTED, type: ACTIONS.CLAIM_SEARCH_STARTED,
data: { query: query }, data: { query: query },
@ -976,12 +976,15 @@ export function doPurchaseList(page: number = 1, pageSize: number = PAGE_SIZE) {
}; };
} }
export const doCheckPendingClaims = (onConfirmed: Function) => ( export const doCheckPendingClaims = (onChannelConfirmed: Function) => (
dispatch: Dispatch, dispatch: Dispatch,
getState: GetState getState: GetState
) => { ) => {
if (onChannelConfirmed) {
onChannelConfirmCallback = onChannelConfirmed;
}
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
const checkTxoList = checkPendingCallbacks => { const checkTxoList = () => {
const state = getState(); const state = getState();
const pendingById = Object.assign({}, selectPendingClaimsById(state)); const pendingById = Object.assign({}, selectPendingClaimsById(state));
const pendingTxos = (Object.values(pendingById): any).map(p => p.txid); const pendingTxos = (Object.values(pendingById): any).map(p => p.txid);
@ -1022,7 +1025,10 @@ export const doCheckPendingClaims = (onConfirmed: Function) => (
}) })
); );
} }
checkPendingCallbacks.forEach(cb => cb()); const channelClaims = claims.filter(claim => claim.value_type === 'channel');
if (channelClaims.length && onChannelConfirmCallback) {
channelClaims.forEach(claim => onChannelConfirmCallback(claim));
}
if (Object.keys(pendingById).length === 0) { if (Object.keys(pendingById).length === 0) {
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
} }
@ -1035,6 +1041,6 @@ export const doCheckPendingClaims = (onConfirmed: Function) => (
}; };
// do something with onConfirmed (typically get blocklist for channel) // do something with onConfirmed (typically get blocklist for channel)
checkPendingInterval = setInterval(() => { checkPendingInterval = setInterval(() => {
checkTxoList(checkPendingCallbacks); checkTxoList();
}, 30000); }, 30000);
}; };