support repost amount
bugfix resolve reposted claims inline refactor resolve reposts further refactor bugfix
This commit is contained in:
parent
e3c05268e5
commit
ce9f720bbd
5 changed files with 126 additions and 64 deletions
42
dist/bundle.es.js
vendored
42
dist/bundle.es.js
vendored
|
@ -2364,7 +2364,7 @@ const makeSelectAmountForUri = uri => reselect.createSelector(makeSelectClaimFor
|
||||||
return claim && claim.amount;
|
return claim && claim.amount;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectEffectiveAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
const makeSelectEffectiveAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri, false), claim => {
|
||||||
return claim && claim.meta && typeof claim.meta.effective_amount === 'string' && Number(claim.meta.effective_amount);
|
return claim && claim.meta && typeof claim.meta.effective_amount === 'string' && Number(claim.meta.effective_amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3193,7 +3193,9 @@ function batchActions(...actions) {
|
||||||
|
|
||||||
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function doResolveUris(uris, returnCachedClaims = false) {
|
function _asyncToGenerator(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 doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const normalizedUris = uris.map(normalizeURI);
|
const normalizedUris = uris.map(normalizeURI);
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -3226,20 +3228,32 @@ function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
|
|
||||||
const resolveInfo = {};
|
const resolveInfo = {};
|
||||||
|
|
||||||
return lbryProxy.resolve(_extends$5({ urls: urisToResolve }, options)).then(result => {
|
return lbryProxy.resolve(_extends$5({ urls: urisToResolve }, options)).then((() => {
|
||||||
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
var _ref = _asyncToGenerator(function* (result) {
|
||||||
|
let repostedResults = {};
|
||||||
|
const repostsToResolve = [];
|
||||||
const fallbackResolveInfo = {
|
const fallbackResolveInfo = {
|
||||||
stream: null,
|
stream: null,
|
||||||
claimsInChannel: null,
|
claimsInChannel: null,
|
||||||
channel: null
|
channel: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function processResult(result, resolveInfo = {}, checkReposts = false) {
|
||||||
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
// Flow has terrible Object.entries support
|
// Flow has terrible Object.entries support
|
||||||
// https://github.com/facebook/flow/issues/2221
|
// https://github.com/facebook/flow/issues/2221
|
||||||
if (uriResolveInfo) {
|
if (uriResolveInfo) {
|
||||||
if (uriResolveInfo.error) {
|
if (uriResolveInfo.error) {
|
||||||
resolveInfo[uri] = _extends$5({}, fallbackResolveInfo);
|
resolveInfo[uri] = _extends$5({}, fallbackResolveInfo);
|
||||||
} else {
|
} else {
|
||||||
|
if (checkReposts) {
|
||||||
|
if (uriResolveInfo.reposted_claim) {
|
||||||
|
const repostUrl = uriResolveInfo.reposted_claim.permanent_url;
|
||||||
|
if (!resolvingUris.includes(repostUrl)) {
|
||||||
|
repostsToResolve.push(repostUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let result = {};
|
let result = {};
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
if (uriResolveInfo.value_type === 'channel') {
|
||||||
result.channel = uriResolveInfo;
|
result.channel = uriResolveInfo;
|
||||||
|
@ -3257,6 +3271,17 @@ function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
processResult(result, resolveInfo, resolveReposts);
|
||||||
|
|
||||||
|
if (repostsToResolve.length) {
|
||||||
|
dispatch({
|
||||||
|
type: RESOLVE_URIS_STARTED,
|
||||||
|
data: { uris: repostsToResolve, debug: 'reposts' }
|
||||||
|
});
|
||||||
|
repostedResults = yield lbryProxy.resolve(_extends$5({ urls: repostsToResolve }, options));
|
||||||
|
}
|
||||||
|
processResult(repostedResults, resolveInfo);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: RESOLVE_URIS_COMPLETED,
|
type: RESOLVE_URIS_COMPLETED,
|
||||||
|
@ -3264,6 +3289,11 @@ function doResolveUris(uris, returnCachedClaims = false) {
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return function (_x) {
|
||||||
|
return _ref.apply(this, arguments);
|
||||||
|
};
|
||||||
|
})());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4269,7 +4299,7 @@ const selectTakeOverAmount = reselect.createSelector(selectState$3, selectMyClai
|
||||||
|
|
||||||
var _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function _asyncToGenerator(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"); }); }; }
|
||||||
|
|
||||||
const doResetThumbnailStatus = () => dispatch => {
|
const doResetThumbnailStatus = () => dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -4603,7 +4633,7 @@ const doCheckReflectingFiles = () => (dispatch, getState) => {
|
||||||
let reflectorCheckInterval;
|
let reflectorCheckInterval;
|
||||||
|
|
||||||
const checkFileList = (() => {
|
const checkFileList = (() => {
|
||||||
var _ref = _asyncToGenerator(function* () {
|
var _ref = _asyncToGenerator$1(function* () {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const reflectingById = selectReflectingById(state);
|
const reflectingById = selectReflectingById(state);
|
||||||
const ids = Object.keys(reflectingById);
|
const ids = Object.keys(reflectingById);
|
||||||
|
|
1
dist/flow-typed/Claim.js
vendored
1
dist/flow-typed/Claim.js
vendored
|
@ -32,6 +32,7 @@ declare type GenericClaim = {
|
||||||
type: 'claim' | 'update' | 'support',
|
type: 'claim' | 'update' | 'support',
|
||||||
value_type: 'stream' | 'channel',
|
value_type: 'stream' | 'channel',
|
||||||
signing_channel?: ChannelClaim,
|
signing_channel?: ChannelClaim,
|
||||||
|
reposted_claim?: GenericClaim,
|
||||||
repost_channel_url?: string,
|
repost_channel_url?: string,
|
||||||
repost_url?: string,
|
repost_url?: string,
|
||||||
repost_bid_amount?: string,
|
repost_bid_amount?: string,
|
||||||
|
|
1
flow-typed/Claim.js
vendored
1
flow-typed/Claim.js
vendored
|
@ -32,6 +32,7 @@ declare type GenericClaim = {
|
||||||
type: 'claim' | 'update' | 'support',
|
type: 'claim' | 'update' | 'support',
|
||||||
value_type: 'stream' | 'channel',
|
value_type: 'stream' | 'channel',
|
||||||
signing_channel?: ChannelClaim,
|
signing_channel?: ChannelClaim,
|
||||||
|
reposted_claim?: GenericClaim,
|
||||||
repost_channel_url?: string,
|
repost_channel_url?: string,
|
||||||
repost_url?: string,
|
repost_url?: string,
|
||||||
repost_bid_amount?: string,
|
repost_bid_amount?: string,
|
||||||
|
|
|
@ -18,7 +18,13 @@ import { batchActions } from 'util/batch-actions';
|
||||||
import { createNormalizedClaimSearchKey } from 'util/claim';
|
import { createNormalizedClaimSearchKey } from 'util/claim';
|
||||||
import { PAGE_SIZE } from 'constants/claim';
|
import { PAGE_SIZE } from 'constants/claim';
|
||||||
|
|
||||||
export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean = false) {
|
type ResolveEntries = Array<[string, GenericClaim]>;
|
||||||
|
|
||||||
|
export function doResolveUris(
|
||||||
|
uris: Array<string>,
|
||||||
|
returnCachedClaims: boolean = false,
|
||||||
|
resolveReposts: boolean = true
|
||||||
|
) {
|
||||||
return (dispatch: Dispatch, getState: GetState) => {
|
return (dispatch: Dispatch, getState: GetState) => {
|
||||||
const normalizedUris = uris.map(normalizeURI);
|
const normalizedUris = uris.map(normalizeURI);
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -57,20 +63,32 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
|
||||||
},
|
},
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
return Lbry.resolve({ urls: urisToResolve, ...options }).then((result: ResolveResponse) => {
|
return Lbry.resolve({ urls: urisToResolve, ...options }).then(
|
||||||
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
async (result: ResolveResponse) => {
|
||||||
|
let repostedResults = {};
|
||||||
|
const repostsToResolve = [];
|
||||||
const fallbackResolveInfo = {
|
const fallbackResolveInfo = {
|
||||||
stream: null,
|
stream: null,
|
||||||
claimsInChannel: null,
|
claimsInChannel: null,
|
||||||
channel: null,
|
channel: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function processResult(result, resolveInfo = {}, checkReposts = false) {
|
||||||
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
// Flow has terrible Object.entries support
|
// Flow has terrible Object.entries support
|
||||||
// https://github.com/facebook/flow/issues/2221
|
// https://github.com/facebook/flow/issues/2221
|
||||||
if (uriResolveInfo) {
|
if (uriResolveInfo) {
|
||||||
if (uriResolveInfo.error) {
|
if (uriResolveInfo.error) {
|
||||||
resolveInfo[uri] = { ...fallbackResolveInfo };
|
resolveInfo[uri] = { ...fallbackResolveInfo };
|
||||||
} else {
|
} else {
|
||||||
|
if (checkReposts) {
|
||||||
|
if (uriResolveInfo.reposted_claim) {
|
||||||
|
const repostUrl = uriResolveInfo.reposted_claim.permanent_url;
|
||||||
|
if (!resolvingUris.includes(repostUrl)) {
|
||||||
|
repostsToResolve.push(repostUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let result = {};
|
let result = {};
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
if (uriResolveInfo.value_type === 'channel') {
|
||||||
result.channel = uriResolveInfo;
|
result.channel = uriResolveInfo;
|
||||||
|
@ -91,13 +109,25 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
processResult(result, resolveInfo, resolveReposts);
|
||||||
|
|
||||||
|
if (repostsToResolve.length) {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.RESOLVE_URIS_STARTED,
|
||||||
|
data: { uris: repostsToResolve, debug: 'reposts' },
|
||||||
|
});
|
||||||
|
repostedResults = await Lbry.resolve({ urls: repostsToResolve, ...options });
|
||||||
|
}
|
||||||
|
processResult(repostedResults, resolveInfo);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.RESOLVE_URIS_COMPLETED,
|
type: ACTIONS.RESOLVE_URIS_COMPLETED,
|
||||||
data: { resolveInfo },
|
data: { resolveInfo },
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ export const makeSelectAmountForUri = (uri: string) =>
|
||||||
|
|
||||||
export const makeSelectEffectiveAmountForUri = (uri: string) =>
|
export const makeSelectEffectiveAmountForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri, false),
|
||||||
claim => {
|
claim => {
|
||||||
return (
|
return (
|
||||||
claim &&
|
claim &&
|
||||||
|
|
Loading…
Reference in a new issue