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
92
dist/bundle.es.js
vendored
92
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,44 +3228,72 @@ 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
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flow has terrible Object.entries support
|
function processResult(result, resolveInfo = {}, checkReposts = false) {
|
||||||
// https://github.com/facebook/flow/issues/2221
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
if (uriResolveInfo) {
|
// Flow has terrible Object.entries support
|
||||||
if (uriResolveInfo.error) {
|
// https://github.com/facebook/flow/issues/2221
|
||||||
resolveInfo[uri] = _extends$5({}, fallbackResolveInfo);
|
if (uriResolveInfo) {
|
||||||
} else {
|
if (uriResolveInfo.error) {
|
||||||
let result = {};
|
resolveInfo[uri] = _extends$5({}, fallbackResolveInfo);
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
} else {
|
||||||
result.channel = uriResolveInfo;
|
if (checkReposts) {
|
||||||
// $FlowFixMe
|
if (uriResolveInfo.reposted_claim) {
|
||||||
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
const repostUrl = uriResolveInfo.reposted_claim.permanent_url;
|
||||||
} else {
|
if (!resolvingUris.includes(repostUrl)) {
|
||||||
result.stream = uriResolveInfo;
|
repostsToResolve.push(repostUrl);
|
||||||
if (uriResolveInfo.signing_channel) {
|
}
|
||||||
result.channel = uriResolveInfo.signing_channel;
|
}
|
||||||
result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0;
|
}
|
||||||
|
let result = {};
|
||||||
|
if (uriResolveInfo.value_type === 'channel') {
|
||||||
|
result.channel = uriResolveInfo;
|
||||||
|
// $FlowFixMe
|
||||||
|
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
||||||
|
} else {
|
||||||
|
result.stream = uriResolveInfo;
|
||||||
|
if (uriResolveInfo.signing_channel) {
|
||||||
|
result.channel = uriResolveInfo.signing_channel;
|
||||||
|
result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $FlowFixMe
|
||||||
|
resolveInfo[uri] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $FlowFixMe
|
});
|
||||||
resolveInfo[uri] = result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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({
|
||||||
|
type: RESOLVE_URIS_COMPLETED,
|
||||||
|
data: { resolveInfo }
|
||||||
|
});
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatch({
|
return function (_x) {
|
||||||
type: RESOLVE_URIS_COMPLETED,
|
return _ref.apply(this, arguments);
|
||||||
data: { resolveInfo }
|
};
|
||||||
});
|
})());
|
||||||
return result;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,47 +63,71 @@ 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,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flow has terrible Object.entries support
|
function processResult(result, resolveInfo = {}, checkReposts = false) {
|
||||||
// https://github.com/facebook/flow/issues/2221
|
Object.entries(result).forEach(([uri, uriResolveInfo]) => {
|
||||||
if (uriResolveInfo) {
|
// Flow has terrible Object.entries support
|
||||||
if (uriResolveInfo.error) {
|
// https://github.com/facebook/flow/issues/2221
|
||||||
resolveInfo[uri] = { ...fallbackResolveInfo };
|
if (uriResolveInfo) {
|
||||||
} else {
|
if (uriResolveInfo.error) {
|
||||||
let result = {};
|
resolveInfo[uri] = { ...fallbackResolveInfo };
|
||||||
if (uriResolveInfo.value_type === 'channel') {
|
} else {
|
||||||
result.channel = uriResolveInfo;
|
if (checkReposts) {
|
||||||
// $FlowFixMe
|
if (uriResolveInfo.reposted_claim) {
|
||||||
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
const repostUrl = uriResolveInfo.reposted_claim.permanent_url;
|
||||||
} else {
|
if (!resolvingUris.includes(repostUrl)) {
|
||||||
result.stream = uriResolveInfo;
|
repostsToResolve.push(repostUrl);
|
||||||
if (uriResolveInfo.signing_channel) {
|
}
|
||||||
result.channel = uriResolveInfo.signing_channel;
|
}
|
||||||
result.claimsInChannel =
|
}
|
||||||
(uriResolveInfo.signing_channel.meta &&
|
let result = {};
|
||||||
uriResolveInfo.signing_channel.meta.claims_in_channel) ||
|
if (uriResolveInfo.value_type === 'channel') {
|
||||||
0;
|
result.channel = uriResolveInfo;
|
||||||
|
// $FlowFixMe
|
||||||
|
result.claimsInChannel = uriResolveInfo.meta.claims_in_channel;
|
||||||
|
} else {
|
||||||
|
result.stream = uriResolveInfo;
|
||||||
|
if (uriResolveInfo.signing_channel) {
|
||||||
|
result.channel = uriResolveInfo.signing_channel;
|
||||||
|
result.claimsInChannel =
|
||||||
|
(uriResolveInfo.signing_channel.meta &&
|
||||||
|
uriResolveInfo.signing_channel.meta.claims_in_channel) ||
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $FlowFixMe
|
||||||
|
resolveInfo[uri] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $FlowFixMe
|
});
|
||||||
resolveInfo[uri] = result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
processResult(result, resolveInfo, resolveReposts);
|
||||||
|
|
||||||
dispatch({
|
if (repostsToResolve.length) {
|
||||||
type: ACTIONS.RESOLVE_URIS_COMPLETED,
|
dispatch({
|
||||||
data: { resolveInfo },
|
type: ACTIONS.RESOLVE_URIS_STARTED,
|
||||||
});
|
data: { uris: repostsToResolve, debug: 'reposts' },
|
||||||
return result;
|
});
|
||||||
});
|
repostedResults = await Lbry.resolve({ urls: repostsToResolve, ...options });
|
||||||
|
}
|
||||||
|
processResult(repostedResults, resolveInfo);
|
||||||
|
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.RESOLVE_URIS_COMPLETED,
|
||||||
|
data: { resolveInfo },
|
||||||
|
});
|
||||||
|
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