Compare commits
34 commits
Author | SHA1 | Date | |
---|---|---|---|
|
0f930c4a7b | ||
|
32b5787071 | ||
|
129b0ea3fa | ||
|
e3bc848263 | ||
|
372e559cae | ||
|
49b9db5aae | ||
|
12a2ffc708 | ||
|
95fa26f836 | ||
|
dc264ec50c | ||
|
aeb1f533b5 | ||
|
d016d8057b | ||
|
0302a2f8d6 | ||
|
8fa92d872d | ||
|
e4d0662100 | ||
|
036aa59086 | ||
|
c76dfbde27 | ||
|
7cc9923ed9 | ||
|
60bd918d5e | ||
|
9ebfc927d0 | ||
|
54ca8c4320 | ||
|
bee9bf38dd | ||
|
aabae5ce59 | ||
|
a327385cdf | ||
|
64ce7aa99c | ||
|
34dfd384e4 | ||
|
707c60b813 | ||
|
8f66a2fe7c | ||
|
729a4831ad | ||
|
88370997b4 | ||
|
b93598b0ff | ||
|
4cbb9a35c3 | ||
|
04ce1df03d | ||
|
347fe25e85 | ||
|
e66698eadc |
20 changed files with 683 additions and 390 deletions
436
dist/bundle.es.js
vendored
436
dist/bundle.es.js
vendored
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
Object.defineProperty(exports, '__esModule', { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||||
|
|
||||||
require('proxy-polyfill');
|
require('proxy-polyfill');
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
var reselect = require('reselect');
|
var reselect = require('reselect');
|
||||||
|
var fromEntries = _interopDefault(require('@ungap/from-entries'));
|
||||||
|
|
||||||
const MINIMUM_PUBLISH_BID = 0.00000001;
|
const MINIMUM_PUBLISH_BID = 0.00000001;
|
||||||
|
|
||||||
|
@ -716,7 +719,7 @@ const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
|
||||||
const THEME = 'theme';
|
const THEME = 'theme';
|
||||||
const THEMES = 'themes';
|
const THEMES = 'themes';
|
||||||
const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
||||||
const AUTOPLAY = 'autoplay';
|
const AUTOPLAY_MEDIA = 'autoplay';
|
||||||
const AUTOPLAY_NEXT = 'autoplay_next';
|
const AUTOPLAY_NEXT = 'autoplay_next';
|
||||||
const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
||||||
const AUTO_DOWNLOAD = 'auto_download';
|
const AUTO_DOWNLOAD = 'auto_download';
|
||||||
|
@ -732,6 +735,8 @@ const ENABLE_PUBLISH_PREVIEW = 'enable-publish-preview';
|
||||||
const TILE_LAYOUT = 'tile_layout';
|
const TILE_LAYOUT = 'tile_layout';
|
||||||
const VIDEO_THEATER_MODE = 'video_theater_mode';
|
const VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||||
const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
||||||
|
const CUSTOM_COMMENTS_SERVER_ENABLED = 'custom_comments_server_enabled';
|
||||||
|
const CUSTOM_COMMENTS_SERVER_URL = 'custom_comments_server_url';
|
||||||
|
|
||||||
// mobile settings
|
// mobile settings
|
||||||
const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
||||||
|
@ -765,7 +770,7 @@ var settings = /*#__PURE__*/Object.freeze({
|
||||||
THEME: THEME,
|
THEME: THEME,
|
||||||
THEMES: THEMES,
|
THEMES: THEMES,
|
||||||
AUTOMATIC_DARK_MODE_ENABLED: AUTOMATIC_DARK_MODE_ENABLED,
|
AUTOMATIC_DARK_MODE_ENABLED: AUTOMATIC_DARK_MODE_ENABLED,
|
||||||
AUTOPLAY: AUTOPLAY,
|
AUTOPLAY_MEDIA: AUTOPLAY_MEDIA,
|
||||||
AUTOPLAY_NEXT: AUTOPLAY_NEXT,
|
AUTOPLAY_NEXT: AUTOPLAY_NEXT,
|
||||||
OS_NOTIFICATIONS_ENABLED: OS_NOTIFICATIONS_ENABLED,
|
OS_NOTIFICATIONS_ENABLED: OS_NOTIFICATIONS_ENABLED,
|
||||||
AUTO_DOWNLOAD: AUTO_DOWNLOAD,
|
AUTO_DOWNLOAD: AUTO_DOWNLOAD,
|
||||||
|
@ -781,6 +786,8 @@ var settings = /*#__PURE__*/Object.freeze({
|
||||||
TILE_LAYOUT: TILE_LAYOUT,
|
TILE_LAYOUT: TILE_LAYOUT,
|
||||||
VIDEO_THEATER_MODE: VIDEO_THEATER_MODE,
|
VIDEO_THEATER_MODE: VIDEO_THEATER_MODE,
|
||||||
VIDEO_PLAYBACK_RATE: VIDEO_PLAYBACK_RATE,
|
VIDEO_PLAYBACK_RATE: VIDEO_PLAYBACK_RATE,
|
||||||
|
CUSTOM_COMMENTS_SERVER_ENABLED: CUSTOM_COMMENTS_SERVER_ENABLED,
|
||||||
|
CUSTOM_COMMENTS_SERVER_URL: CUSTOM_COMMENTS_SERVER_URL,
|
||||||
BACKGROUND_PLAY_ENABLED: BACKGROUND_PLAY_ENABLED,
|
BACKGROUND_PLAY_ENABLED: BACKGROUND_PLAY_ENABLED,
|
||||||
FOREGROUND_NOTIFICATION_ENABLED: FOREGROUND_NOTIFICATION_ENABLED,
|
FOREGROUND_NOTIFICATION_ENABLED: FOREGROUND_NOTIFICATION_ENABLED,
|
||||||
KEEP_DAEMON_RUNNING: KEEP_DAEMON_RUNNING,
|
KEEP_DAEMON_RUNNING: KEEP_DAEMON_RUNNING,
|
||||||
|
@ -1033,7 +1040,7 @@ var daemon_settings = /*#__PURE__*/Object.freeze({
|
||||||
const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA];
|
const SDK_SYNC_KEYS = [LBRYUM_SERVERS, SHARE_USAGE_DATA];
|
||||||
|
|
||||||
// CLIENT
|
// CLIENT
|
||||||
const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, AUTOPLAY, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED];
|
const CLIENT_SYNC_KEYS = [SHOW_MATURE, HIDE_REPOSTS, SHOW_ANONYMOUS, INSTANT_PURCHASE_ENABLED, INSTANT_PURCHASE_MAX, THEME, AUTOPLAY_MEDIA, AUTOPLAY_NEXT, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED, LANGUAGE];
|
||||||
|
|
||||||
var shared_preferences = /*#__PURE__*/Object.freeze({
|
var shared_preferences = /*#__PURE__*/Object.freeze({
|
||||||
SDK_SYNC_KEYS: SDK_SYNC_KEYS,
|
SDK_SYNC_KEYS: SDK_SYNC_KEYS,
|
||||||
|
@ -1190,6 +1197,7 @@ const Lbry = {
|
||||||
utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params),
|
utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params),
|
||||||
support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params),
|
support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params),
|
||||||
purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params),
|
purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params),
|
||||||
|
txo_list: (params = {}) => daemonCallWithResult('txo_list', params),
|
||||||
|
|
||||||
sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params),
|
sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params),
|
||||||
sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params),
|
sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params),
|
||||||
|
@ -1472,7 +1480,7 @@ const channelNameMinLength = 1;
|
||||||
const claimIdMaxLength = 40;
|
const claimIdMaxLength = 40;
|
||||||
|
|
||||||
// see https://spec.lbry.com/#urls
|
// see https://spec.lbry.com/#urls
|
||||||
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%\{\}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
||||||
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
||||||
const regexPartProtocol = '^((?:lbry://)?)';
|
const regexPartProtocol = '^((?:lbry://)?)';
|
||||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||||
|
@ -1480,6 +1488,11 @@ const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
||||||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||||
const separateQuerystring = new RegExp(queryStringBreaker);
|
const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
|
|
||||||
|
const MOD_SEQUENCE_SEPARATOR = '*';
|
||||||
|
const MOD_CLAIM_ID_SEPARATOR_OLD = '#';
|
||||||
|
const MOD_CLAIM_ID_SEPARATOR = ':';
|
||||||
|
const MOD_BID_POSITION_SEPARATOR = '$';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
||||||
* messages for invalid names.
|
* messages for invalid names.
|
||||||
|
@ -1581,11 +1594,11 @@ function parseURIModifier(modSeperator, modValue) {
|
||||||
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modSeperator === '#') {
|
if (modSeperator === MOD_CLAIM_ID_SEPARATOR || MOD_CLAIM_ID_SEPARATOR_OLD) {
|
||||||
claimId = modValue;
|
claimId = modValue;
|
||||||
} else if (modSeperator === ':') {
|
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) {
|
||||||
claimSequence = modValue;
|
claimSequence = modValue;
|
||||||
} else if (modSeperator === '$') {
|
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) {
|
||||||
bidPosition = modValue;
|
bidPosition = modValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1716,6 +1729,25 @@ function convertToShareLink(URL) {
|
||||||
}, true, 'https://open.lbry.com/');
|
}, true, 'https://open.lbry.com/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splitBySeparator(uri) {
|
||||||
|
const protocolLength = 7;
|
||||||
|
return uri.startsWith('lbry://') ? uri.slice(protocolLength).split(/[#:*]/) : uri.split(/#:\*\$/);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isURIEqual(uriA, uriB) {
|
||||||
|
const parseA = parseURI(normalizeURI(uriA));
|
||||||
|
const parseB = parseURI(normalizeURI(uriB));
|
||||||
|
if (parseA.isChannel) {
|
||||||
|
if (parseB.isChannel && parseA.channelClaimId === parseB.channelClaimId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (parseA.streamClaimId === parseB.streamClaimId) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// underscore's deep equal function
|
// underscore's deep equal function
|
||||||
// https://github.com/jashkenas/underscore/blob/master/underscore.js#L1189
|
// https://github.com/jashkenas/underscore/blob/master/underscore.js#L1189
|
||||||
|
@ -1839,11 +1871,12 @@ function extractUserState(rawObj) {
|
||||||
app_welcome_version,
|
app_welcome_version,
|
||||||
sharing_3P,
|
sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections
|
savedCollections
|
||||||
} = rawObj.value;
|
} = rawObj.value;
|
||||||
|
|
||||||
return _extends$1({}, subscriptions ? { subscriptions } : {}, following ? { following } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, coin_swap_codes ? { coin_swap_codes } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}, unpublishedCollections ? { unpublishedCollections } : {}, builtinCollections ? { builtinCollections } : {}, savedCollections ? { savedCollections } : {});
|
return _extends$1({}, subscriptions ? { subscriptions } : {}, following ? { following } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, coin_swap_codes ? { coin_swap_codes } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}, unpublishedCollections ? { unpublishedCollections } : {}, editedCollections ? { editedCollections } : {}, builtinCollections ? { builtinCollections } : {}, savedCollections ? { savedCollections } : {});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -1861,6 +1894,7 @@ function doPopulateSharedUserState(sharedSettings) {
|
||||||
app_welcome_version,
|
app_welcome_version,
|
||||||
sharing_3P,
|
sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections
|
savedCollections
|
||||||
} = extractUserState(sharedSettings);
|
} = extractUserState(sharedSettings);
|
||||||
|
@ -1876,6 +1910,7 @@ function doPopulateSharedUserState(sharedSettings) {
|
||||||
welcomeVersion: app_welcome_version,
|
welcomeVersion: app_welcome_version,
|
||||||
allowAnalytics: sharing_3P,
|
allowAnalytics: sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections
|
savedCollections
|
||||||
}
|
}
|
||||||
|
@ -2370,7 +2405,13 @@ var _extends$3 = Object.assign || function (target) { for (var i = 1; i < argume
|
||||||
|
|
||||||
const selectState$1 = state => state.claims || {};
|
const selectState$1 = state => state.claims || {};
|
||||||
|
|
||||||
const selectClaimsById = reselect.createSelector(selectState$1, state => state.byId || {});
|
const selectById = reselect.createSelector(selectState$1, state => state.byId || {});
|
||||||
|
|
||||||
|
const selectPendingClaimsById = reselect.createSelector(selectState$1, state => state.pendingById || {});
|
||||||
|
|
||||||
|
const selectClaimsById = reselect.createSelector(selectById, selectPendingClaimsById, (byId, pendingById) => {
|
||||||
|
return Object.assign(byId, pendingById); // do I need merged to keep metadata?
|
||||||
|
});
|
||||||
|
|
||||||
const selectClaimIdsByUri = reselect.createSelector(selectState$1, state => state.claimsByUri || {});
|
const selectClaimIdsByUri = reselect.createSelector(selectState$1, state => state.claimsByUri || {});
|
||||||
|
|
||||||
|
@ -2405,21 +2446,21 @@ const selectClaimsByUri = reselect.createSelector(selectClaimIdsByUri, selectCla
|
||||||
|
|
||||||
const selectAllClaimsByChannel = reselect.createSelector(selectState$1, state => state.paginatedClaimsByChannel || {});
|
const selectAllClaimsByChannel = reselect.createSelector(selectState$1, state => state.paginatedClaimsByChannel || {});
|
||||||
|
|
||||||
const selectPendingIds = reselect.createSelector(selectState$1, state => state.pendingIds || []);
|
const selectPendingIds = reselect.createSelector(selectState$1, state => Object.keys(state.pendingById) || []);
|
||||||
|
|
||||||
const selectPendingClaims = reselect.createSelector(selectPendingIds, selectClaimsById, (pendingIds, byId) => pendingIds.map(id => byId[id]));
|
const selectPendingClaims = reselect.createSelector(selectPendingClaimsById, pendingById => Object.values(pendingById));
|
||||||
|
|
||||||
const makeSelectClaimIsPending = uri => reselect.createSelector(selectClaimIdsByUri, selectPendingIds, (idsByUri, pendingIds) => {
|
const makeSelectClaimIsPending = uri => reselect.createSelector(selectClaimIdsByUri, selectPendingClaimsById, (idsByUri, pendingById) => {
|
||||||
const claimId = idsByUri[normalizeURI(uri)];
|
const claimId = idsByUri[normalizeURI(uri)];
|
||||||
|
|
||||||
if (claimId) {
|
if (claimId) {
|
||||||
return pendingIds.some(i => i === claimId);
|
return Boolean(pendingById[claimId]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectClaimIdIsPending = claimId => reselect.createSelector(selectPendingIds, pendingIds => {
|
const makeSelectClaimIdIsPending = claimId => reselect.createSelector(selectPendingClaimsById, pendingById => {
|
||||||
return pendingIds.some(i => i === claimId);
|
return Boolean(pendingById[claimId]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectClaimIdForUri = uri => reselect.createSelector(selectClaimIdsByUri, claimIds => claimIds[uri]);
|
const makeSelectClaimIdForUri = uri => reselect.createSelector(selectClaimIdsByUri, claimIds => claimIds[uri]);
|
||||||
|
@ -2454,7 +2495,7 @@ const makeSelectClaimForUri = (uri, returnRepost = true) => reselect.createSelec
|
||||||
const channelUrl = claim.signing_channel && (claim.signing_channel.canonical_url || claim.signing_channel.permanent_url);
|
const channelUrl = claim.signing_channel && (claim.signing_channel.canonical_url || claim.signing_channel.permanent_url);
|
||||||
|
|
||||||
return _extends$3({}, repostedClaim, {
|
return _extends$3({}, repostedClaim, {
|
||||||
repost_url: uri,
|
repost_url: normalizeURI(uri),
|
||||||
repost_channel_url: channelUrl,
|
repost_channel_url: channelUrl,
|
||||||
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount
|
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount
|
||||||
});
|
});
|
||||||
|
@ -2552,25 +2593,18 @@ const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(
|
||||||
return claimIds.map(claimId => byId[claimId]);
|
return claimIds.map(claimId => byId[claimId]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// THIS IS LEFT OVER FROM ONE TAB CHANNEL_CONTENT
|
||||||
const makeSelectTotalClaimsInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
const makeSelectTotalClaimsInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
||||||
const byChannel = allClaims[uri] || {};
|
const byChannel = allClaims[uri] || {};
|
||||||
return byChannel['itemCount'];
|
return byChannel['itemCount'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// THIS IS LEFT OVER FROM ONE_TAB CHANNEL CONTENT
|
||||||
const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
||||||
const byChannel = allClaims[uri] || {};
|
const byChannel = allClaims[uri] || {};
|
||||||
return byChannel['pageCount'];
|
return byChannel['pageCount'];
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectClaimsInChannelForCurrentPageState = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, selectCurrentChannelPage, (byId, allClaims, page) => {
|
|
||||||
const byChannel = allClaims[uri] || {};
|
|
||||||
const claimIds = byChannel[page || 1];
|
|
||||||
|
|
||||||
if (!claimIds) return claimIds;
|
|
||||||
|
|
||||||
return claimIds.map(claimId => byId[claimId]);
|
|
||||||
});
|
|
||||||
|
|
||||||
const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
|
||||||
const metadata = claim && claim.value;
|
const metadata = claim && claim.value;
|
||||||
return metadata || (claim === undefined ? undefined : null);
|
return metadata || (claim === undefined ? undefined : null);
|
||||||
|
@ -2697,34 +2731,24 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p
|
||||||
|
|
||||||
const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {});
|
const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {});
|
||||||
|
|
||||||
const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => {
|
const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingClaimsById, pendingById => {
|
||||||
let uriIsChannel;
|
|
||||||
let uriStreamName;
|
let uriStreamName;
|
||||||
let uriChannelName;
|
let uriChannelName;
|
||||||
try {
|
try {
|
||||||
({
|
({ streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri));
|
||||||
isChannel: uriIsChannel,
|
|
||||||
streamName: uriStreamName,
|
|
||||||
channelName: uriChannelName
|
|
||||||
} = parseURI(uri));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const pendingClaims = pending.map(id => claims[id]);
|
const pendingClaims = Object.values(pendingById);
|
||||||
const matchingClaim = pendingClaims.find(claim => {
|
const matchingClaim = pendingClaims.find(claim => {
|
||||||
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
|
return claim.normalized_name === uriChannelName || claim.normalized_name === uriStreamName;
|
||||||
if (isChannel) {
|
|
||||||
return channelName === uriChannelName;
|
|
||||||
} else {
|
|
||||||
return streamName === uriStreamName;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return matchingClaim || null;
|
return matchingClaim || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
|
const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[normalizeURI(uri)]);
|
||||||
|
|
||||||
const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize));
|
const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[normalizeURI(uri)] / pageSize));
|
||||||
|
|
||||||
const makeSelectNsfwCountFromUris = uris => reselect.createSelector(selectClaimsByUri, claims => uris.reduce((acc, uri) => {
|
const makeSelectNsfwCountFromUris = uris => reselect.createSelector(selectClaimsByUri, claims => uris.reduce((acc, uri) => {
|
||||||
const claim = claims[uri];
|
const claim = claims[uri];
|
||||||
|
@ -2734,21 +2758,6 @@ const makeSelectNsfwCountFromUris = uris => reselect.createSelector(selectClaims
|
||||||
return acc;
|
return acc;
|
||||||
}, 0));
|
}, 0));
|
||||||
|
|
||||||
const makeSelectNsfwCountForChannel = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, selectCurrentChannelPage, (byId, allClaims, page) => {
|
|
||||||
const byChannel = allClaims[uri] || {};
|
|
||||||
const claimIds = byChannel[page || 1];
|
|
||||||
|
|
||||||
if (!claimIds) return 0;
|
|
||||||
|
|
||||||
return claimIds.reduce((acc, claimId) => {
|
|
||||||
const claim = byId[claimId];
|
|
||||||
if (isClaimNsfw(claim)) {
|
|
||||||
return acc + 1;
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
const makeSelectOmittedCountForChannel = uri => reselect.createSelector(makeSelectTotalItemsForChannel(uri), makeSelectTotalClaimsInChannelSearch(uri), (claimsInChannel, claimsInSearch) => {
|
const makeSelectOmittedCountForChannel = uri => reselect.createSelector(makeSelectTotalItemsForChannel(uri), makeSelectTotalClaimsInChannelSearch(uri), (claimsInChannel, claimsInSearch) => {
|
||||||
if (claimsInChannel && typeof claimsInSearch === 'number' && claimsInSearch >= 0) {
|
if (claimsInChannel && typeof claimsInSearch === 'number' && claimsInSearch >= 0) {
|
||||||
return claimsInChannel - claimsInSearch;
|
return claimsInChannel - claimsInSearch;
|
||||||
|
@ -3642,7 +3651,7 @@ const makeSelectCollectionIsMine = id => reselect.createSelector(selectMyCollect
|
||||||
|
|
||||||
const selectMyPublishedCollections = reselect.createSelector(selectResolvedCollections, selectPendingCollections, selectMyEditedCollections, selectMyCollectionIds, (resolved, pending, edited, myIds) => {
|
const selectMyPublishedCollections = reselect.createSelector(selectResolvedCollections, selectPendingCollections, selectMyEditedCollections, selectMyCollectionIds, (resolved, pending, edited, myIds) => {
|
||||||
// all resolved in myIds, plus those in pending and edited
|
// all resolved in myIds, plus those in pending and edited
|
||||||
const myPublishedCollections = Object.fromEntries(Object.entries(pending).concat(Object.entries(resolved).filter(([key, val]) => myIds.includes(key) &&
|
const myPublishedCollections = fromEntries(Object.entries(pending).concat(Object.entries(resolved).filter(([key, val]) => myIds.includes(key) &&
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
!pending[key])));
|
!pending[key])));
|
||||||
// now add in edited:
|
// now add in edited:
|
||||||
|
@ -3653,7 +3662,7 @@ const selectMyPublishedCollections = reselect.createSelector(selectResolvedColle
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
||||||
const myCollections = Object.fromEntries(
|
const myCollections = fromEntries(
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(published).filter(([key, collection]) => {
|
Object.entries(published).filter(([key, collection]) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -3663,7 +3672,7 @@ const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublis
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
||||||
const myCollections = Object.fromEntries(
|
const myCollections = fromEntries(
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(published).filter(([key, collection]) => {
|
Object.entries(published).filter(([key, collection]) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -3678,7 +3687,7 @@ const makeSelectMyPublishedCollectionForId = id => reselect.createSelector(selec
|
||||||
// selectResolvedCollections,
|
// selectResolvedCollections,
|
||||||
// selectSavedCollectionIds,
|
// selectSavedCollectionIds,
|
||||||
// (resolved, myIds) => {
|
// (resolved, myIds) => {
|
||||||
// const mySavedCollections = Object.fromEntries(
|
// const mySavedCollections = fromEntries(
|
||||||
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
||||||
// );
|
// );
|
||||||
// return mySavedCollections;
|
// return mySavedCollections;
|
||||||
|
@ -3690,10 +3699,24 @@ const makeSelectIsResolvingCollectionForId = id => reselect.createSelector(selec
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCollections, selectResolvedCollections, selectMyUnpublishedCollections, selectMyEditedCollections, selectPendingCollections, (bLists, rLists, uLists, eLists, pLists) => {
|
const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCollections, selectResolvedCollections, selectMyUnpublishedCollections, selectMyEditedCollections, selectPendingCollections, (bLists, rLists, uLists, eLists, pLists) => {
|
||||||
const collection = bLists[id] || uLists[id] || eLists[id] || rLists[id] || pLists[id];
|
const collection = bLists[id] || uLists[id] || eLists[id] || pLists[id] || rLists[id];
|
||||||
return collection;
|
return collection;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const makeSelectClaimUrlInCollection = url => reselect.createSelector(selectBuiltinCollections, selectMyPublishedCollections, selectMyUnpublishedCollections, selectMyEditedCollections, selectPendingCollections, (bLists, myRLists, uLists, eLists, pLists) => {
|
||||||
|
const collections = [bLists, uLists, eLists, myRLists, pLists];
|
||||||
|
const itemsInCollections = [];
|
||||||
|
collections.map(list => {
|
||||||
|
Object.entries(list).forEach(([key, value]) => {
|
||||||
|
// $FlowFixMe
|
||||||
|
value.items.map(item => {
|
||||||
|
itemsInCollections.push(item);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return itemsInCollections.includes(url);
|
||||||
|
});
|
||||||
|
|
||||||
const makeSelectCollectionForIdHasClaimUrl = (id, url) => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items.includes(url));
|
const makeSelectCollectionForIdHasClaimUrl = (id, url) => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items.includes(url));
|
||||||
|
|
||||||
const makeSelectUrlsForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items);
|
const makeSelectUrlsForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items);
|
||||||
|
@ -3707,23 +3730,51 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
|
||||||
return ids;
|
return ids;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
|
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(state => state.content.shuffleList, makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (shuffleState, urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
|
||||||
|
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
} else if (claim) {
|
} else if (claim) {
|
||||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
|
||||||
if (index > -1) return index;
|
if (index > -1) return index;
|
||||||
return claim;
|
return claim;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, urls) => {
|
const makeSelectPreviousUrlForCollectionAndUrl = (id, url) => reselect.createSelector(state => state.content.shuffleList, state => state.content.loopList, makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (shuffleState, loopState, index, urls) => {
|
||||||
|
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||||
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
let nextUrl;
|
||||||
|
if (index === 0 && loopList) {
|
||||||
|
nextUrl = listUrls[listUrls.length - 1];
|
||||||
|
} else {
|
||||||
|
nextUrl = listUrls[index - 1];
|
||||||
|
}
|
||||||
|
return nextUrl || null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(state => state.content.shuffleList, state => state.content.loopList, makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (shuffleState, loopState, index, urls) => {
|
||||||
|
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||||
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
|
||||||
|
if (index > -1) {
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
// We'll get the next playble url
|
// We'll get the next playble url
|
||||||
const remainingUrls = urls.slice(index + 1);
|
let remainingUrls = listUrls.slice(index + 1);
|
||||||
const nextUrl = remainingUrls.find(u => claims[u].value.stream_type && (claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio'));
|
if (!remainingUrls.length && loopList) {
|
||||||
|
remainingUrls = listUrls.slice(0);
|
||||||
|
}
|
||||||
|
const nextUrl = remainingUrls && remainingUrls[0];
|
||||||
return nextUrl || null;
|
return nextUrl || null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -3739,7 +3790,13 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
|
||||||
if (collection.itemCount !== undefined) {
|
if (collection.itemCount !== undefined) {
|
||||||
return collection.itemCount;
|
return collection.itemCount;
|
||||||
}
|
}
|
||||||
return collection.items.length;
|
let itemCount = 0;
|
||||||
|
collection.items.map(item => {
|
||||||
|
if (item) {
|
||||||
|
itemCount += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return itemCount;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -3748,6 +3805,9 @@ 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 onChannelConfirmCallback;
|
||||||
|
let checkPendingInterval;
|
||||||
|
|
||||||
function doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) {
|
function doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const normalizedUris = uris.map(normalizeURI);
|
const normalizedUris = uris.map(normalizeURI);
|
||||||
|
@ -4086,7 +4146,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
|
||||||
|
@ -4140,7 +4200,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({
|
||||||
|
@ -4442,11 +4502,15 @@ function doCollectionPublish(options, localId) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function doCollectionPublishUpdate(options) {
|
function doCollectionPublishUpdate(options, isBackgroundUpdate) {
|
||||||
return dispatch => {
|
return (dispatch, getState) => {
|
||||||
// TODO: implement one click update
|
// TODO: implement one click update
|
||||||
|
|
||||||
const updateParams = {
|
const updateParams = isBackgroundUpdate ? {
|
||||||
|
blocking: true,
|
||||||
|
claim_id: options.claim_id,
|
||||||
|
clear_claims: true
|
||||||
|
} : {
|
||||||
bid: creditsToString(options.bid),
|
bid: creditsToString(options.bid),
|
||||||
title: options.title,
|
title: options.title,
|
||||||
thumbnail_url: options.thumbnail_url,
|
thumbnail_url: options.thumbnail_url,
|
||||||
|
@ -4456,16 +4520,25 @@ function doCollectionPublishUpdate(options) {
|
||||||
locations: [],
|
locations: [],
|
||||||
blocking: true,
|
blocking: true,
|
||||||
claim_id: options.claim_id,
|
claim_id: options.claim_id,
|
||||||
clear_claims: true
|
clear_claims: true,
|
||||||
|
replace: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isBackgroundUpdate && updateParams.claim_id) {
|
||||||
|
const state = getState();
|
||||||
|
updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state);
|
||||||
|
} else if (options.claims) {
|
||||||
|
updateParams['claims'] = options.claims;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.tags) {
|
if (options.tags) {
|
||||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.claims) {
|
if (options.channel_id) {
|
||||||
updateParams['claims'] = options.claims;
|
updateParams['channel_id'] = options.channel_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: COLLECTION_PUBLISH_UPDATE_STARTED
|
type: COLLECTION_PUBLISH_UPDATE_STARTED
|
||||||
|
@ -4490,7 +4563,6 @@ function doCollectionPublishUpdate(options) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dispatch(doCheckPendingClaims());
|
dispatch(doCheckPendingClaims());
|
||||||
dispatch(doFetchCollectionListMine(1, 10));
|
|
||||||
return resolve(collectionClaim);
|
return resolve(collectionClaim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4570,48 +4642,63 @@ function doPurchaseList(page = 1, pageSize = PAGE_SIZE) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const doCheckPendingClaims = onConfirmed => (dispatch, getState) => {
|
const doCheckPendingClaims = onChannelConfirmed => (dispatch, getState) => {
|
||||||
let claimCheckInterval;
|
if (onChannelConfirmed) {
|
||||||
|
onChannelConfirmCallback = onChannelConfirmed;
|
||||||
const checkClaimList = () => {
|
}
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
|
const checkTxoList = () => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const pendingIdSet = new Set(selectPendingIds(state));
|
const pendingById = Object.assign({}, selectPendingClaimsById(state));
|
||||||
|
const pendingTxos = Object.values(pendingById).map(p => p.txid);
|
||||||
|
// use collections
|
||||||
const pendingCollections = selectPendingCollections(state);
|
const pendingCollections = selectPendingCollections(state);
|
||||||
lbryProxy.claim_list({ page: 1, page_size: 10 }).then(result => {
|
if (pendingTxos.length) {
|
||||||
const claims = result.items;
|
lbryProxy.txo_list({ txid: pendingTxos }).then(result => {
|
||||||
const claimsToConfirm = [];
|
const txos = result.items;
|
||||||
claims.forEach(claim => {
|
const idsToConfirm = [];
|
||||||
const { claim_id: claimId } = claim;
|
txos.forEach(txo => {
|
||||||
if (claim.confirmations > 0 && pendingIdSet.has(claimId)) {
|
if (txo.claim_id && txo.confirmations > 0) {
|
||||||
pendingIdSet.delete(claimId);
|
idsToConfirm.push(txo.claim_id);
|
||||||
if (Object.keys(pendingCollections).includes(claim.claim_id)) {
|
delete pendingById[txo.claim_id];
|
||||||
dispatch(doFetchItemsInCollection({ collectionId: claim.claim_id }));
|
|
||||||
dispatch(doCollectionDelete(claim.claim_id, 'pending'));
|
|
||||||
}
|
|
||||||
claimsToConfirm.push(claim);
|
|
||||||
if (onConfirmed) {
|
|
||||||
onConfirmed(claim);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (claimsToConfirm.length) {
|
return { idsToConfirm, pendingById };
|
||||||
|
}).then(results => {
|
||||||
|
const { idsToConfirm, pendingById } = results;
|
||||||
|
if (idsToConfirm.length) {
|
||||||
|
return lbryProxy.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => {
|
||||||
|
const claims = results.items;
|
||||||
|
const collectionIds = claims.filter(c => c.value_type === 'collection').map(c => c.claim_id);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: UPDATE_CONFIRMED_CLAIMS,
|
type: UPDATE_CONFIRMED_CLAIMS,
|
||||||
data: {
|
data: {
|
||||||
claims: claimsToConfirm
|
claims: claims,
|
||||||
|
pending: pendingById
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (collectionIds.length) {
|
||||||
|
dispatch(doFetchItemsInCollections({
|
||||||
|
collectionIds
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const channelClaims = claims.filter(claim => claim.value_type === 'channel');
|
||||||
|
if (channelClaims.length && onChannelConfirmCallback) {
|
||||||
|
channelClaims.forEach(claim => onChannelConfirmCallback(claim));
|
||||||
|
}
|
||||||
|
if (Object.keys(pendingById).length === 0) {
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return pendingIdSet.size;
|
|
||||||
}).then(len => {
|
|
||||||
if (!len) {
|
|
||||||
clearInterval(claimCheckInterval);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
// do something with onConfirmed (typically get blocklist for channel)
|
||||||
claimCheckInterval = setInterval(() => {
|
checkPendingInterval = setInterval(() => {
|
||||||
checkClaimList();
|
checkTxoList();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4621,7 +4708,7 @@ const getTimestamp = () => {
|
||||||
return Math.floor(Date.now() / 1000);
|
return Math.floor(Date.now() / 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const FETCH_BATCH_SIZE = 10;
|
const FETCH_BATCH_SIZE = 50;
|
||||||
|
|
||||||
const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => {
|
const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
|
@ -4728,7 +4815,8 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
|
||||||
batches[i] = lbryProxy.claim_search({
|
batches[i] = lbryProxy.claim_search({
|
||||||
claim_ids: claim.value.claims,
|
claim_ids: claim.value.claims,
|
||||||
page: i + 1,
|
page: i + 1,
|
||||||
page_size: batchSize
|
page_size: batchSize,
|
||||||
|
no_totals: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const itemsInBatches = yield Promise.all(batches);
|
const itemsInBatches = yield Promise.all(batches);
|
||||||
|
@ -5545,7 +5633,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
|
||||||
data: _extends$7({}, publishFormValue)
|
data: _extends$7({}, publishFormValue)
|
||||||
});
|
});
|
||||||
|
|
||||||
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => dispatch => {
|
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) => dispatch => {
|
||||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||||
let thumbnail, fileExt, fileName, fileType;
|
let thumbnail, fileExt, fileName, fileType;
|
||||||
|
|
||||||
|
@ -5579,13 +5667,17 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data
|
body: data
|
||||||
}).then(res => res.text()).then(text => text.length ? JSON.parse(text) : {}).then(json => {
|
}).then(res => res.text()).then(text => text.length ? JSON.parse(text) : {}).then(json => {
|
||||||
return json.success ? dispatch({
|
if (!json.success) return uploadError(json.message || downMessage);
|
||||||
|
if (cb) {
|
||||||
|
cb(json.data.serveUrl);
|
||||||
|
}
|
||||||
|
return dispatch({
|
||||||
type: UPDATE_PUBLISH_FORM,
|
type: UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: COMPLETE,
|
uploadThumbnailStatus: COMPLETE,
|
||||||
thumbnail: json.data.serveUrl
|
thumbnail: json.data.serveUrl
|
||||||
}
|
}
|
||||||
}) : uploadError(json.message || downMessage);
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
let message = err.message;
|
let message = err.message;
|
||||||
|
|
||||||
|
@ -6001,7 +6093,7 @@ const defaultState = {
|
||||||
fetchingMyChannels: false,
|
fetchingMyChannels: false,
|
||||||
fetchingMyCollections: false,
|
fetchingMyCollections: false,
|
||||||
abandoningById: {},
|
abandoningById: {},
|
||||||
pendingIds: [],
|
pendingById: {},
|
||||||
reflectingById: {},
|
reflectingById: {},
|
||||||
claimSearchError: false,
|
claimSearchError: false,
|
||||||
claimSearchByQuery: {},
|
claimSearchByQuery: {},
|
||||||
|
@ -6035,7 +6127,7 @@ function handleClaimAction(state, action) {
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||||
const pendingIds = state.pendingIds;
|
const pendingById = state.pendingById;
|
||||||
let newResolvingUrls = new Set(state.resolvingUris);
|
let newResolvingUrls = new Set(state.resolvingUris);
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
|
|
||||||
|
@ -6045,7 +6137,7 @@ function handleClaimAction(state, action) {
|
||||||
const channel = channelFromResolve || stream && stream.signing_channel;
|
const channel = channelFromResolve || stream && stream.signing_channel;
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
if (pendingIds.includes(stream.claim_id)) {
|
if (pendingById[stream.claim_id]) {
|
||||||
byId[stream.claim_id] = mergeClaims(stream, byId[stream.claim_id]);
|
byId[stream.claim_id] = mergeClaims(stream, byId[stream.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[stream.claim_id] = stream;
|
byId[stream.claim_id] = stream;
|
||||||
|
@ -6075,7 +6167,7 @@ function handleClaimAction(state, action) {
|
||||||
channelClaimCounts[channel.canonical_url] = claimsInChannel;
|
channelClaimCounts[channel.canonical_url] = claimsInChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pendingIds.includes(channel.claim_id)) {
|
if (pendingById[channel.claim_id]) {
|
||||||
byId[channel.claim_id] = mergeClaims(channel, byId[channel.claim_id]);
|
byId[channel.claim_id] = mergeClaims(channel, byId[channel.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[channel.claim_id] = channel;
|
byId[channel.claim_id] = channel;
|
||||||
|
@ -6088,7 +6180,7 @@ function handleClaimAction(state, action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collection) {
|
if (collection) {
|
||||||
if (pendingIds.includes(collection.claim_id)) {
|
if (pendingById[collection.claim_id]) {
|
||||||
byId[collection.claim_id] = mergeClaims(collection, byId[collection.claim_id]);
|
byId[collection.claim_id] = mergeClaims(collection, byId[collection.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[collection.claim_id] = collection;
|
byId[collection.claim_id] = collection;
|
||||||
|
@ -6105,7 +6197,7 @@ function handleClaimAction(state, action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
newResolvingUrls.delete(url);
|
newResolvingUrls.delete(url);
|
||||||
if (!stream && !channel && !collection && !pendingIds.includes(byUri[url])) {
|
if (!stream && !channel && !collection && !pendingById[byUri[url]]) {
|
||||||
byUri[url] = null;
|
byUri[url] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6145,34 +6237,33 @@ reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, {
|
||||||
});
|
});
|
||||||
|
|
||||||
reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
||||||
const { result, resolve } = action.data;
|
const { result } = action.data;
|
||||||
const claims = result.items;
|
const claims = result.items;
|
||||||
const page = result.page;
|
const page = result.page;
|
||||||
const totalItems = result.total_items;
|
const totalItems = result.total_items;
|
||||||
|
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
let urlsForCurrentPage = [];
|
let urlsForCurrentPage = [];
|
||||||
|
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
|
|
||||||
claims.forEach(claim => {
|
claims.forEach(claim => {
|
||||||
const { permanent_url: permanentUri, claim_id: claimId } = claim;
|
const { permanent_url: permanentUri, claim_id: claimId, canonical_url: canonicalUri } = claim;
|
||||||
if (claim.type && claim.type.match(/claim|update/)) {
|
if (claim.type && claim.type.match(/claim|update/)) {
|
||||||
urlsForCurrentPage.push(permanentUri);
|
urlsForCurrentPage.push(permanentUri);
|
||||||
if (claim.confirmations < 1) {
|
if (claim.confirmations < 1) {
|
||||||
pendingIdSet.add(claimId);
|
pendingById[claimId] = claim;
|
||||||
} else if (!resolve && pendingIdSet.has(claimId) && claim.confirmations > 0) {
|
if (byId[claimId]) {
|
||||||
pendingIdSet.delete(claimId);
|
|
||||||
}
|
|
||||||
if (pendingIds.includes(claimId)) {
|
|
||||||
byId[claimId] = mergeClaims(claim, byId[claimId]);
|
byId[claimId] = mergeClaims(claim, byId[claimId]);
|
||||||
} else {
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
byUri[permanentUri] = claimId;
|
byUri[permanentUri] = claimId;
|
||||||
|
byUri[canonicalUri] = claimId;
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6181,7 +6272,7 @@ reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => {
|
||||||
isFetchingClaimListMine: false,
|
isFetchingClaimListMine: false,
|
||||||
myClaims: Array.from(myClaimIds),
|
myClaims: Array.from(myClaimIds),
|
||||||
byId,
|
byId,
|
||||||
pendingIds: Array.from(pendingIdSet),
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
myClaimsPageResults: urlsForCurrentPage,
|
myClaimsPageResults: urlsForCurrentPage,
|
||||||
myClaimsPageNumber: page,
|
myClaimsPageNumber: page,
|
||||||
|
@ -6193,9 +6284,8 @@ reducers[FETCH_CHANNEL_LIST_STARTED] = state => Object.assign({}, state, { fetch
|
||||||
|
|
||||||
reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
const { claims } = action.data;
|
const { claims } = action.data;
|
||||||
const myClaims = state.myClaims || [];
|
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myChannelClaims;
|
let myChannelClaims;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
|
@ -6208,7 +6298,12 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
myChannelClaims = new Set(state.myChannelClaims);
|
myChannelClaims = new Set(state.myChannelClaims);
|
||||||
claims.forEach(claim => {
|
claims.forEach(claim => {
|
||||||
const { claims_in_channel: claimsInChannel } = claim.meta;
|
const { claims_in_channel: claimsInChannel } = claim.meta;
|
||||||
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
|
const {
|
||||||
|
canonical_url: canonicalUrl,
|
||||||
|
permanent_url: permanentUrl,
|
||||||
|
claim_id: claimId,
|
||||||
|
confirmations
|
||||||
|
} = claim;
|
||||||
|
|
||||||
byUri[canonicalUrl] = claimId;
|
byUri[canonicalUrl] = claimId;
|
||||||
byUri[permanentUrl] = claimId;
|
byUri[permanentUrl] = claimId;
|
||||||
|
@ -6217,7 +6312,14 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
myChannelClaims.add(claimId);
|
myChannelClaims.add(claimId);
|
||||||
if (!pendingIds.some(c => c === claimId)) {
|
if (confirmations < 1) {
|
||||||
|
pendingById[claimId] = claim;
|
||||||
|
if (byId[claimId]) {
|
||||||
|
byId[claimId] = mergeClaims(claim, byId[claimId]);
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
|
@ -6226,6 +6328,7 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
channelClaimCounts,
|
channelClaimCounts,
|
||||||
fetchingMyChannels: false,
|
fetchingMyChannels: false,
|
||||||
|
@ -6248,7 +6351,7 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => {
|
||||||
const { claims } = action.data;
|
const { claims } = action.data;
|
||||||
const myClaims = state.myClaims || [];
|
const myClaims = state.myClaims || [];
|
||||||
let myClaimIds = new Set(myClaims);
|
let myClaimIds = new Set(myClaims);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myCollectionClaimsSet = new Set([]);
|
let myCollectionClaimsSet = new Set([]);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
|
@ -6256,7 +6359,12 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => {
|
||||||
if (claims.length) {
|
if (claims.length) {
|
||||||
myCollectionClaimsSet = new Set(state.myCollectionClaims);
|
myCollectionClaimsSet = new Set(state.myCollectionClaims);
|
||||||
claims.forEach(claim => {
|
claims.forEach(claim => {
|
||||||
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
|
const {
|
||||||
|
canonical_url: canonicalUrl,
|
||||||
|
permanent_url: permanentUrl,
|
||||||
|
claim_id: claimId,
|
||||||
|
confirmations
|
||||||
|
} = claim;
|
||||||
|
|
||||||
byUri[canonicalUrl] = claimId;
|
byUri[canonicalUrl] = claimId;
|
||||||
byUri[permanentUrl] = claimId;
|
byUri[permanentUrl] = claimId;
|
||||||
|
@ -6264,7 +6372,14 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
myCollectionClaimsSet.add(claimId);
|
myCollectionClaimsSet.add(claimId);
|
||||||
// we don't want to overwrite a pending result with a resolve
|
// we don't want to overwrite a pending result with a resolve
|
||||||
if (!pendingIds.some(c => c === claimId)) {
|
if (confirmations < 1) {
|
||||||
|
pendingById[claimId] = claim;
|
||||||
|
if (byId[claimId]) {
|
||||||
|
byId[claimId] = mergeClaims(claim, byId[claimId]);
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
|
@ -6273,6 +6388,7 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => {
|
||||||
|
|
||||||
return _extends$9({}, state, {
|
return _extends$9({}, state, {
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
fetchingMyCollections: false,
|
fetchingMyCollections: false,
|
||||||
myCollectionClaims: Array.from(myCollectionClaimsSet),
|
myCollectionClaims: Array.from(myCollectionClaimsSet),
|
||||||
|
@ -6358,9 +6474,8 @@ reducers[ABANDON_CLAIM_STARTED] = (state, action) => {
|
||||||
reducers[UPDATE_PENDING_CLAIMS] = (state, action) => {
|
reducers[UPDATE_PENDING_CLAIMS] = (state, action) => {
|
||||||
const { claims: pendingClaims } = action.data;
|
const { claims: pendingClaims } = action.data;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds;
|
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
const myChannelClaims = new Set(state.myChannelClaims);
|
const myChannelClaims = new Set(state.myChannelClaims);
|
||||||
|
|
||||||
|
@ -6368,7 +6483,7 @@ reducers[UPDATE_PENDING_CLAIMS] = (state, action) => {
|
||||||
pendingClaims.forEach(claim => {
|
pendingClaims.forEach(claim => {
|
||||||
let newClaim;
|
let newClaim;
|
||||||
const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim;
|
const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim;
|
||||||
pendingIdSet.add(claimId);
|
pendingById[claimId] = claim; // make sure we don't need to merge?
|
||||||
const oldClaim = byId[claimId];
|
const oldClaim = byId[claimId];
|
||||||
if (oldClaim && oldClaim.canonical_url) {
|
if (oldClaim && oldClaim.canonical_url) {
|
||||||
newClaim = mergeClaims(oldClaim, claim);
|
newClaim = mergeClaims(oldClaim, claim);
|
||||||
|
@ -6388,21 +6503,22 @@ reducers[UPDATE_PENDING_CLAIMS] = (state, action) => {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
myClaims: Array.from(myClaimIds),
|
myClaims: Array.from(myClaimIds),
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
myChannelClaims: Array.from(myChannelClaims),
|
myChannelClaims: Array.from(myChannelClaims),
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri
|
||||||
pendingIds: Array.from(pendingIdSet)
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => {
|
reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => {
|
||||||
const { claims: confirmedClaims } = action.data;
|
const {
|
||||||
|
claims: confirmedClaims,
|
||||||
|
pending: pendingClaims
|
||||||
|
} = action.data;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds;
|
//
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
|
|
||||||
confirmedClaims.forEach(claim => {
|
confirmedClaims.forEach(claim => {
|
||||||
const { permanent_url: permanentUri, claim_id: claimId, type } = claim;
|
const { claim_id: claimId, type } = claim;
|
||||||
let newClaim = claim;
|
let newClaim = claim;
|
||||||
const oldClaim = byId[claimId];
|
const oldClaim = byId[claimId];
|
||||||
if (oldClaim && oldClaim.canonical_url) {
|
if (oldClaim && oldClaim.canonical_url) {
|
||||||
|
@ -6410,11 +6526,10 @@ reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => {
|
||||||
}
|
}
|
||||||
if (type && type.match(/claim|update|channel/)) {
|
if (type && type.match(/claim|update|channel/)) {
|
||||||
byId[claimId] = newClaim;
|
byId[claimId] = newClaim;
|
||||||
pendingIdSet.delete(claimId);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
pendingIds: Array.from(pendingIdSet),
|
pendingById: pendingClaims,
|
||||||
byId,
|
byId,
|
||||||
claimsByUri: byUri
|
claimsByUri: byUri
|
||||||
});
|
});
|
||||||
|
@ -7657,8 +7772,15 @@ const collectionsReducer = handleActions({
|
||||||
|
|
||||||
[COLLECTION_PENDING]: (state, action) => {
|
[COLLECTION_PENDING]: (state, action) => {
|
||||||
const { localId, claimId } = action.data;
|
const { localId, claimId } = action.data;
|
||||||
const { edited: editList, unpublished: unpublishedList, pending: pendingList } = state;
|
const {
|
||||||
|
resolved: resolvedList,
|
||||||
|
edited: editList,
|
||||||
|
unpublished: unpublishedList,
|
||||||
|
pending: pendingList
|
||||||
|
} = state;
|
||||||
|
|
||||||
const newEditList = Object.assign({}, editList);
|
const newEditList = Object.assign({}, editList);
|
||||||
|
const newResolvedList = Object.assign({}, resolvedList);
|
||||||
const newUnpublishedList = Object.assign({}, unpublishedList);
|
const newUnpublishedList = Object.assign({}, unpublishedList);
|
||||||
const newPendingList = Object.assign({}, pendingList);
|
const newPendingList = Object.assign({}, pendingList);
|
||||||
|
|
||||||
|
@ -7668,7 +7790,7 @@ const collectionsReducer = handleActions({
|
||||||
delete newUnpublishedList[localId];
|
delete newUnpublishedList[localId];
|
||||||
} else {
|
} else {
|
||||||
// edit update
|
// edit update
|
||||||
newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
|
newPendingList[claimId] = Object.assign({}, newEditList[claimId] || newResolvedList[claimId]);
|
||||||
delete newEditList[claimId];
|
delete newEditList[claimId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7720,8 +7842,14 @@ const collectionsReducer = handleActions({
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
[USER_STATE_POPULATE]: (state, action) => {
|
[USER_STATE_POPULATE]: (state, action) => {
|
||||||
const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
|
const {
|
||||||
|
builtinCollections,
|
||||||
|
savedCollections,
|
||||||
|
unpublishedCollections,
|
||||||
|
editedCollections
|
||||||
|
} = action.data;
|
||||||
return _extends$e({}, state, {
|
return _extends$e({}, state, {
|
||||||
|
edited: editedCollections || state.edited,
|
||||||
unpublished: unpublishedCollections || state.unpublished,
|
unpublished: unpublishedCollections || state.unpublished,
|
||||||
builtin: builtinCollections || state.builtin,
|
builtin: builtinCollections || state.builtin,
|
||||||
saved: savedCollections || state.saved
|
saved: savedCollections || state.saved
|
||||||
|
@ -7921,6 +8049,7 @@ exports.formatFullPrice = formatFullPrice;
|
||||||
exports.isClaimNsfw = isClaimNsfw;
|
exports.isClaimNsfw = isClaimNsfw;
|
||||||
exports.isNameValid = isNameValid;
|
exports.isNameValid = isNameValid;
|
||||||
exports.isURIClaimable = isURIClaimable;
|
exports.isURIClaimable = isURIClaimable;
|
||||||
|
exports.isURIEqual = isURIEqual;
|
||||||
exports.isURIValid = isURIValid;
|
exports.isURIValid = isURIValid;
|
||||||
exports.makeSelectAbandoningClaimById = makeSelectAbandoningClaimById;
|
exports.makeSelectAbandoningClaimById = makeSelectAbandoningClaimById;
|
||||||
exports.makeSelectAmountForUri = makeSelectAmountForUri;
|
exports.makeSelectAmountForUri = makeSelectAmountForUri;
|
||||||
|
@ -7937,8 +8066,8 @@ exports.makeSelectClaimIsMine = makeSelectClaimIsMine;
|
||||||
exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw;
|
exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw;
|
||||||
exports.makeSelectClaimIsPending = makeSelectClaimIsPending;
|
exports.makeSelectClaimIsPending = makeSelectClaimIsPending;
|
||||||
exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder;
|
exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder;
|
||||||
|
exports.makeSelectClaimUrlInCollection = makeSelectClaimUrlInCollection;
|
||||||
exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased;
|
exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased;
|
||||||
exports.makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState;
|
|
||||||
exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
|
exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
|
||||||
exports.makeSelectCollectionForId = makeSelectCollectionForId;
|
exports.makeSelectCollectionForId = makeSelectCollectionForId;
|
||||||
exports.makeSelectCollectionForIdHasClaimUrl = makeSelectCollectionForIdHasClaimUrl;
|
exports.makeSelectCollectionForIdHasClaimUrl = makeSelectCollectionForIdHasClaimUrl;
|
||||||
|
@ -7972,13 +8101,13 @@ exports.makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage;
|
||||||
exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage;
|
exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage;
|
||||||
exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId;
|
exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId;
|
||||||
exports.makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl;
|
exports.makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl;
|
||||||
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
|
|
||||||
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
|
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
|
||||||
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
|
exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel;
|
||||||
exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
|
exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
|
||||||
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
||||||
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
||||||
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
||||||
|
exports.makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl;
|
||||||
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
||||||
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
||||||
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
||||||
|
@ -8138,5 +8267,6 @@ exports.selectWalletState = selectWalletState;
|
||||||
exports.selectWalletUnlockPending = selectWalletUnlockPending;
|
exports.selectWalletUnlockPending = selectWalletUnlockPending;
|
||||||
exports.selectWalletUnlockResult = selectWalletUnlockResult;
|
exports.selectWalletUnlockResult = selectWalletUnlockResult;
|
||||||
exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded;
|
exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded;
|
||||||
|
exports.splitBySeparator = splitBySeparator;
|
||||||
exports.toQueryString = toQueryString;
|
exports.toQueryString = toQueryString;
|
||||||
exports.walletReducer = walletReducer;
|
exports.walletReducer = walletReducer;
|
||||||
|
|
3
dist/flow-typed/Lbry.js
vendored
3
dist/flow-typed/Lbry.js
vendored
|
@ -75,7 +75,7 @@ declare type BalanceResponse = {
|
||||||
|
|
||||||
declare type ResolveResponse = {
|
declare type ResolveResponse = {
|
||||||
// Keys are the url(s) passed to resolve
|
// Keys are the url(s) passed to resolve
|
||||||
[string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, claimsInChannel?: number },
|
[string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, collection?: CollectionClaim, claimsInChannel?: number },
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type GetResponse = FileListItem & { error?: string };
|
declare type GetResponse = FileListItem & { error?: string };
|
||||||
|
@ -351,6 +351,7 @@ declare type LbryTypes = {
|
||||||
address_unused: (params: {}) => Promise<string>, // New address
|
address_unused: (params: {}) => Promise<string>, // New address
|
||||||
address_list: (params: {}) => Promise<string>,
|
address_list: (params: {}) => Promise<string>,
|
||||||
transaction_list: (params: {}) => Promise<TxListResponse>,
|
transaction_list: (params: {}) => Promise<TxListResponse>,
|
||||||
|
txo_list: (params: {}) => Promise<any>,
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
sync_hash: (params: {}) => Promise<string>,
|
sync_hash: (params: {}) => Promise<string>,
|
||||||
|
|
5
dist/flow-typed/npm/from-entries.js
vendored
Normal file
5
dist/flow-typed/npm/from-entries.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
declare module '@ungap/from-entries' {
|
||||||
|
declare module.exports: any;
|
||||||
|
}
|
3
flow-typed/Lbry.js
vendored
3
flow-typed/Lbry.js
vendored
|
@ -75,7 +75,7 @@ declare type BalanceResponse = {
|
||||||
|
|
||||||
declare type ResolveResponse = {
|
declare type ResolveResponse = {
|
||||||
// Keys are the url(s) passed to resolve
|
// Keys are the url(s) passed to resolve
|
||||||
[string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, claimsInChannel?: number },
|
[string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, collection?: CollectionClaim, claimsInChannel?: number },
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type GetResponse = FileListItem & { error?: string };
|
declare type GetResponse = FileListItem & { error?: string };
|
||||||
|
@ -351,6 +351,7 @@ declare type LbryTypes = {
|
||||||
address_unused: (params: {}) => Promise<string>, // New address
|
address_unused: (params: {}) => Promise<string>, // New address
|
||||||
address_list: (params: {}) => Promise<string>,
|
address_list: (params: {}) => Promise<string>,
|
||||||
transaction_list: (params: {}) => Promise<TxListResponse>,
|
transaction_list: (params: {}) => Promise<TxListResponse>,
|
||||||
|
txo_list: (params: {}) => Promise<any>,
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
sync_hash: (params: {}) => Promise<string>,
|
sync_hash: (params: {}) => Promise<string>,
|
||||||
|
|
5
flow-typed/npm/from-entries.js
vendored
Normal file
5
flow-typed/npm/from-entries.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
declare module '@ungap/from-entries' {
|
||||||
|
declare module.exports: any;
|
||||||
|
}
|
|
@ -29,6 +29,7 @@
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ungap/from-entries": "^0.2.1",
|
||||||
"proxy-polyfill": "0.1.6",
|
"proxy-polyfill": "0.1.6",
|
||||||
"reselect": "^3.0.0",
|
"reselect": "^3.0.0",
|
||||||
"uuid": "^8.3.1"
|
"uuid": "^8.3.1"
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
|
||||||
export const THEME = 'theme';
|
export const THEME = 'theme';
|
||||||
export const THEMES = 'themes';
|
export const THEMES = 'themes';
|
||||||
export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
||||||
export const AUTOPLAY = 'autoplay';
|
export const AUTOPLAY_MEDIA = 'autoplay';
|
||||||
export const AUTOPLAY_NEXT = 'autoplay_next';
|
export const AUTOPLAY_NEXT = 'autoplay_next';
|
||||||
export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
||||||
export const AUTO_DOWNLOAD = 'auto_download';
|
export const AUTO_DOWNLOAD = 'auto_download';
|
||||||
|
@ -39,6 +39,8 @@ export const ENABLE_PUBLISH_PREVIEW = 'enable-publish-preview';
|
||||||
export const TILE_LAYOUT = 'tile_layout';
|
export const TILE_LAYOUT = 'tile_layout';
|
||||||
export const VIDEO_THEATER_MODE = 'video_theater_mode';
|
export const VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||||
export const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
export const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
||||||
|
export const CUSTOM_COMMENTS_SERVER_ENABLED = 'custom_comments_server_enabled';
|
||||||
|
export const CUSTOM_COMMENTS_SERVER_URL = 'custom_comments_server_url';
|
||||||
|
|
||||||
// mobile settings
|
// mobile settings
|
||||||
export const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
export const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
||||||
|
|
|
@ -21,10 +21,12 @@ export const CLIENT_SYNC_KEYS = [
|
||||||
SETTINGS.INSTANT_PURCHASE_ENABLED,
|
SETTINGS.INSTANT_PURCHASE_ENABLED,
|
||||||
SETTINGS.INSTANT_PURCHASE_MAX,
|
SETTINGS.INSTANT_PURCHASE_MAX,
|
||||||
SETTINGS.THEME,
|
SETTINGS.THEME,
|
||||||
SETTINGS.AUTOPLAY,
|
SETTINGS.AUTOPLAY_MEDIA,
|
||||||
|
SETTINGS.AUTOPLAY_NEXT,
|
||||||
SETTINGS.HIDE_BALANCE,
|
SETTINGS.HIDE_BALANCE,
|
||||||
SETTINGS.HIDE_SPLASH_ANIMATION,
|
SETTINGS.HIDE_SPLASH_ANIMATION,
|
||||||
SETTINGS.FLOATING_PLAYER,
|
SETTINGS.FLOATING_PLAYER,
|
||||||
SETTINGS.DARK_MODE_TIMES,
|
SETTINGS.DARK_MODE_TIMES,
|
||||||
SETTINGS.AUTOMATIC_DARK_MODE_ENABLED,
|
SETTINGS.AUTOMATIC_DARK_MODE_ENABLED,
|
||||||
|
SETTINGS.LANGUAGE,
|
||||||
];
|
];
|
||||||
|
|
|
@ -52,6 +52,8 @@ export {
|
||||||
isURIClaimable,
|
isURIClaimable,
|
||||||
isNameValid,
|
isNameValid,
|
||||||
convertToShareLink,
|
convertToShareLink,
|
||||||
|
splitBySeparator,
|
||||||
|
isURIEqual,
|
||||||
} from 'lbryURI';
|
} from 'lbryURI';
|
||||||
|
|
||||||
// middlware
|
// middlware
|
||||||
|
@ -174,12 +176,14 @@ export {
|
||||||
makeSelectMyPublishedCollectionForId,
|
makeSelectMyPublishedCollectionForId,
|
||||||
makeSelectUnpublishedCollectionForId,
|
makeSelectUnpublishedCollectionForId,
|
||||||
makeSelectCollectionForId,
|
makeSelectCollectionForId,
|
||||||
|
makeSelectClaimUrlInCollection,
|
||||||
makeSelectUrlsForCollectionId,
|
makeSelectUrlsForCollectionId,
|
||||||
makeSelectClaimIdsForCollectionId,
|
makeSelectClaimIdsForCollectionId,
|
||||||
makeSelectNameForCollectionId,
|
makeSelectNameForCollectionId,
|
||||||
makeSelectCountForCollectionId,
|
makeSelectCountForCollectionId,
|
||||||
makeSelectIsResolvingCollectionForId,
|
makeSelectIsResolvingCollectionForId,
|
||||||
makeSelectIndexForUrlInCollection,
|
makeSelectIndexForUrlInCollection,
|
||||||
|
makeSelectPreviousUrlForCollectionAndUrl,
|
||||||
makeSelectNextUrlForCollectionAndUrl,
|
makeSelectNextUrlForCollectionAndUrl,
|
||||||
makeSelectCollectionForIdHasClaimUrl,
|
makeSelectCollectionForIdHasClaimUrl,
|
||||||
} from 'redux/selectors/collections';
|
} from 'redux/selectors/collections';
|
||||||
|
@ -209,7 +213,6 @@ export {
|
||||||
makeSelectTotalItemsForChannel,
|
makeSelectTotalItemsForChannel,
|
||||||
makeSelectTotalPagesForChannel,
|
makeSelectTotalPagesForChannel,
|
||||||
makeSelectNsfwCountFromUris,
|
makeSelectNsfwCountFromUris,
|
||||||
makeSelectNsfwCountForChannel,
|
|
||||||
makeSelectOmittedCountForChannel,
|
makeSelectOmittedCountForChannel,
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
makeSelectChannelForClaimUri,
|
makeSelectChannelForClaimUri,
|
||||||
|
@ -217,7 +220,6 @@ export {
|
||||||
makeSelectMyChannelPermUrlForName,
|
makeSelectMyChannelPermUrlForName,
|
||||||
makeSelectClaimIsPending,
|
makeSelectClaimIsPending,
|
||||||
makeSelectReflectingClaimForUri,
|
makeSelectReflectingClaimForUri,
|
||||||
makeSelectClaimsInChannelForCurrentPageState,
|
|
||||||
makeSelectShortUrlForUri,
|
makeSelectShortUrlForUri,
|
||||||
makeSelectCanonicalUrlForUri,
|
makeSelectCanonicalUrlForUri,
|
||||||
makeSelectPermanentUrlForUri,
|
makeSelectPermanentUrlForUri,
|
||||||
|
|
|
@ -117,6 +117,7 @@ const Lbry: LbryTypes = {
|
||||||
utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params),
|
utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params),
|
||||||
support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params),
|
support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params),
|
||||||
purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params),
|
purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params),
|
||||||
|
txo_list: (params = {}) => daemonCallWithResult('txo_list', params),
|
||||||
|
|
||||||
sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params),
|
sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params),
|
||||||
sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params),
|
sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params),
|
||||||
|
|
|
@ -4,7 +4,7 @@ const channelNameMinLength = 1;
|
||||||
const claimIdMaxLength = 40;
|
const claimIdMaxLength = 40;
|
||||||
|
|
||||||
// see https://spec.lbry.com/#urls
|
// see https://spec.lbry.com/#urls
|
||||||
export const regexInvalidURI = /[ =&#:$@%?;/\\"<>%\{\}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
export const regexInvalidURI = /[ =&#:$@%?;/\\"<>%{}|^~[\]`\u{0000}-\u{0008}\u{000b}-\u{000c}\u{000e}-\u{001F}\u{D800}-\u{DFFF}\u{FFFE}-\u{FFFF}]/u;
|
||||||
export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
export const regexAddress = /^(b|r)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$/;
|
||||||
const regexPartProtocol = '^((?:lbry://)?)';
|
const regexPartProtocol = '^((?:lbry://)?)';
|
||||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||||
|
@ -12,6 +12,11 @@ const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
||||||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||||
const separateQuerystring = new RegExp(queryStringBreaker);
|
const separateQuerystring = new RegExp(queryStringBreaker);
|
||||||
|
|
||||||
|
const MOD_SEQUENCE_SEPARATOR = '*';
|
||||||
|
const MOD_CLAIM_ID_SEPARATOR_OLD = '#';
|
||||||
|
const MOD_CLAIM_ID_SEPARATOR = ':';
|
||||||
|
const MOD_BID_POSITION_SEPARATOR = '$';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
* Parses a LBRY name into its component parts. Throws errors with user-friendly
|
||||||
* messages for invalid names.
|
* messages for invalid names.
|
||||||
|
@ -144,11 +149,11 @@ function parseURIModifier(modSeperator: ?string, modValue: ?string) {
|
||||||
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
throw new Error(__(`No modifier provided after separator %modSeperator%.`, { modSeperator }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modSeperator === '#') {
|
if (modSeperator === MOD_CLAIM_ID_SEPARATOR || MOD_CLAIM_ID_SEPARATOR_OLD) {
|
||||||
claimId = modValue;
|
claimId = modValue;
|
||||||
} else if (modSeperator === ':') {
|
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) {
|
||||||
claimSequence = modValue;
|
claimSequence = modValue;
|
||||||
} else if (modSeperator === '$') {
|
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) {
|
||||||
bidPosition = modValue;
|
bidPosition = modValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,3 +325,22 @@ export function convertToShareLink(URL: string) {
|
||||||
'https://open.lbry.com/'
|
'https://open.lbry.com/'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function splitBySeparator(uri: string) {
|
||||||
|
const protocolLength = 7;
|
||||||
|
return uri.startsWith('lbry://') ? uri.slice(protocolLength).split(/[#:*]/) : uri.split(/#:\*\$/);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isURIEqual(uriA: string, uriB: string) {
|
||||||
|
const parseA = parseURI(normalizeURI(uriA));
|
||||||
|
const parseB = parseURI(normalizeURI(uriB));
|
||||||
|
if (parseA.isChannel) {
|
||||||
|
if (parseB.isChannel && parseA.channelClaimId === parseB.channelClaimId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (parseA.streamClaimId === parseB.streamClaimId) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
selectMyChannelClaims,
|
selectMyChannelClaims,
|
||||||
selectPendingIds,
|
selectPendingIds,
|
||||||
|
selectPendingClaimsById,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
|
||||||
import { doFetchTxoPage } from 'redux/actions/wallet';
|
import { doFetchTxoPage } from 'redux/actions/wallet';
|
||||||
|
@ -20,6 +21,7 @@ import { createNormalizedClaimSearchKey } from 'util/claim';
|
||||||
import { PAGE_SIZE } from 'constants/claim';
|
import { PAGE_SIZE } from 'constants/claim';
|
||||||
import {
|
import {
|
||||||
selectPendingCollections,
|
selectPendingCollections,
|
||||||
|
makeSelectClaimIdsForCollectionId,
|
||||||
} from 'redux/selectors/collections';
|
} from 'redux/selectors/collections';
|
||||||
import {
|
import {
|
||||||
doFetchItemsInCollection,
|
doFetchItemsInCollection,
|
||||||
|
@ -27,6 +29,9 @@ import {
|
||||||
doCollectionDelete,
|
doCollectionDelete,
|
||||||
} from 'redux/actions/collections';
|
} from 'redux/actions/collections';
|
||||||
|
|
||||||
|
let onChannelConfirmCallback;
|
||||||
|
let checkPendingInterval;
|
||||||
|
|
||||||
export function doResolveUris(
|
export function doResolveUris(
|
||||||
uris: Array<string>,
|
uris: Array<string>,
|
||||||
returnCachedClaims: boolean = false,
|
returnCachedClaims: boolean = false,
|
||||||
|
@ -402,7 +407,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,
|
||||||
|
@ -469,7 +474,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 => {
|
||||||
|
@ -826,7 +831,8 @@ export function doCollectionPublish(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doCollectionPublishUpdate(options: {
|
export function doCollectionPublishUpdate(
|
||||||
|
options: {
|
||||||
bid?: string,
|
bid?: string,
|
||||||
blocking?: true,
|
blocking?: true,
|
||||||
title?: string,
|
title?: string,
|
||||||
|
@ -836,8 +842,11 @@ export function doCollectionPublishUpdate(options: {
|
||||||
tags?: Array<Tag>,
|
tags?: Array<Tag>,
|
||||||
languages?: Array<string>,
|
languages?: Array<string>,
|
||||||
claims?: Array<string>,
|
claims?: Array<string>,
|
||||||
}) {
|
channel_id?: string,
|
||||||
return (dispatch: Dispatch): Promise<any> => {
|
},
|
||||||
|
isBackgroundUpdate?: boolean
|
||||||
|
) {
|
||||||
|
return (dispatch: Dispatch, getState: GetState): Promise<any> => {
|
||||||
// TODO: implement one click update
|
// TODO: implement one click update
|
||||||
|
|
||||||
const updateParams: {
|
const updateParams: {
|
||||||
|
@ -845,13 +854,21 @@ export function doCollectionPublishUpdate(options: {
|
||||||
blocking?: true,
|
blocking?: true,
|
||||||
title?: string,
|
title?: string,
|
||||||
thumbnail_url?: string,
|
thumbnail_url?: string,
|
||||||
|
channel_id?: string,
|
||||||
description?: string,
|
description?: string,
|
||||||
claim_id: string,
|
claim_id: string,
|
||||||
tags?: Array<string>,
|
tags?: Array<string>,
|
||||||
languages?: Array<string>,
|
languages?: Array<string>,
|
||||||
claims?: Array<string>,
|
claims?: Array<string>,
|
||||||
clear_claims: boolean,
|
clear_claims: boolean,
|
||||||
} = {
|
replace?: boolean,
|
||||||
|
} = isBackgroundUpdate
|
||||||
|
? {
|
||||||
|
blocking: true,
|
||||||
|
claim_id: options.claim_id,
|
||||||
|
clear_claims: true,
|
||||||
|
}
|
||||||
|
: {
|
||||||
bid: creditsToString(options.bid),
|
bid: creditsToString(options.bid),
|
||||||
title: options.title,
|
title: options.title,
|
||||||
thumbnail_url: options.thumbnail_url,
|
thumbnail_url: options.thumbnail_url,
|
||||||
|
@ -862,15 +879,24 @@ export function doCollectionPublishUpdate(options: {
|
||||||
blocking: true,
|
blocking: true,
|
||||||
claim_id: options.claim_id,
|
claim_id: options.claim_id,
|
||||||
clear_claims: true,
|
clear_claims: true,
|
||||||
|
replace: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isBackgroundUpdate && updateParams.claim_id) {
|
||||||
|
const state = getState();
|
||||||
|
updateParams['claims'] = makeSelectClaimIdsForCollectionId(updateParams.claim_id)(state);
|
||||||
|
} else if (options.claims) {
|
||||||
|
updateParams['claims'] = options.claims;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.tags) {
|
if (options.tags) {
|
||||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.claims) {
|
if (options.channel_id) {
|
||||||
updateParams['claims'] = options.claims;
|
updateParams['channel_id'] = options.channel_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,
|
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,
|
||||||
|
@ -895,7 +921,6 @@ export function doCollectionPublishUpdate(options: {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
dispatch(doCheckPendingClaims());
|
dispatch(doCheckPendingClaims());
|
||||||
dispatch(doFetchCollectionListMine(1, 10));
|
|
||||||
return resolve(collectionClaim);
|
return resolve(collectionClaim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,52 +1000,71 @@ 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
|
||||||
) => {
|
) => {
|
||||||
let claimCheckInterval;
|
if (onChannelConfirmed) {
|
||||||
|
onChannelConfirmCallback = onChannelConfirmed;
|
||||||
const checkClaimList = () => {
|
}
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
|
const checkTxoList = () => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const pendingIdSet = new Set(selectPendingIds(state));
|
const pendingById = Object.assign({}, selectPendingClaimsById(state));
|
||||||
|
const pendingTxos = (Object.values(pendingById): any).map(p => p.txid);
|
||||||
|
// use collections
|
||||||
const pendingCollections = selectPendingCollections(state);
|
const pendingCollections = selectPendingCollections(state);
|
||||||
Lbry.claim_list({ page: 1, page_size: 10 })
|
if (pendingTxos.length) {
|
||||||
|
Lbry.txo_list({ txid: pendingTxos })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
const claims = result.items;
|
const txos = result.items;
|
||||||
const claimsToConfirm = [];
|
const idsToConfirm = [];
|
||||||
claims.forEach(claim => {
|
txos.forEach(txo => {
|
||||||
const { claim_id: claimId } = claim;
|
if (txo.claim_id && txo.confirmations > 0) {
|
||||||
if (claim.confirmations > 0 && pendingIdSet.has(claimId)) {
|
idsToConfirm.push(txo.claim_id);
|
||||||
pendingIdSet.delete(claimId);
|
delete pendingById[txo.claim_id];
|
||||||
if (Object.keys(pendingCollections).includes(claim.claim_id)) {
|
|
||||||
dispatch(doFetchItemsInCollection({ collectionId: claim.claim_id }));
|
|
||||||
dispatch(doCollectionDelete(claim.claim_id, 'pending'));
|
|
||||||
}
|
|
||||||
claimsToConfirm.push(claim);
|
|
||||||
if (onConfirmed) {
|
|
||||||
onConfirmed(claim);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (claimsToConfirm.length) {
|
return { idsToConfirm, pendingById };
|
||||||
|
})
|
||||||
|
.then(results => {
|
||||||
|
const { idsToConfirm, pendingById } = results;
|
||||||
|
if (idsToConfirm.length) {
|
||||||
|
return Lbry.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => {
|
||||||
|
const claims = results.items;
|
||||||
|
const collectionIds = claims
|
||||||
|
.filter(c => c.value_type === 'collection')
|
||||||
|
.map(c => c.claim_id);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.UPDATE_CONFIRMED_CLAIMS,
|
type: ACTIONS.UPDATE_CONFIRMED_CLAIMS,
|
||||||
data: {
|
data: {
|
||||||
claims: claimsToConfirm,
|
claims: claims,
|
||||||
|
pending: pendingById,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
if (collectionIds.length) {
|
||||||
return pendingIdSet.size;
|
dispatch(
|
||||||
|
doFetchItemsInCollections({
|
||||||
|
collectionIds,
|
||||||
})
|
})
|
||||||
.then(len => {
|
);
|
||||||
if (!len) {
|
}
|
||||||
clearInterval(claimCheckInterval);
|
const channelClaims = claims.filter(claim => claim.value_type === 'channel');
|
||||||
|
if (channelClaims.length && onChannelConfirmCallback) {
|
||||||
|
channelClaims.forEach(claim => onChannelConfirmCallback(claim));
|
||||||
|
}
|
||||||
|
if (Object.keys(pendingById).length === 0) {
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
clearInterval(checkPendingInterval);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
// do something with onConfirmed (typically get blocklist for channel)
|
||||||
claimCheckInterval = setInterval(() => {
|
checkPendingInterval = setInterval(() => {
|
||||||
checkClaimList();
|
checkTxoList();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ const getTimestamp = () => {
|
||||||
return Math.floor(Date.now() / 1000);
|
return Math.floor(Date.now() / 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const FETCH_BATCH_SIZE = 10;
|
const FETCH_BATCH_SIZE = 50;
|
||||||
|
|
||||||
export const doLocalCollectionCreate = (
|
export const doLocalCollectionCreate = (
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -165,6 +165,7 @@ export const doFetchItemsInCollections = (
|
||||||
claim_ids: claim.value.claims,
|
claim_ids: claim.value.claims,
|
||||||
page: i + 1,
|
page: i + 1,
|
||||||
page_size: batchSize,
|
page_size: batchSize,
|
||||||
|
no_totals: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const itemsInBatches = await Promise.all(batches);
|
const itemsInBatches = await Promise.all(batches);
|
||||||
|
|
|
@ -69,7 +69,8 @@ export const doUploadThumbnail = (
|
||||||
thumbnailBlob?: File,
|
thumbnailBlob?: File,
|
||||||
fsAdapter?: any,
|
fsAdapter?: any,
|
||||||
fs?: any,
|
fs?: any,
|
||||||
path?: any
|
path?: any,
|
||||||
|
cb?: (string) => void
|
||||||
) => (dispatch: Dispatch) => {
|
) => (dispatch: Dispatch) => {
|
||||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||||
let thumbnail, fileExt, fileName, fileType;
|
let thumbnail, fileExt, fileName, fileType;
|
||||||
|
@ -112,15 +113,17 @@ export const doUploadThumbnail = (
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => (text.length ? JSON.parse(text) : {}))
|
.then(text => (text.length ? JSON.parse(text) : {}))
|
||||||
.then(json => {
|
.then(json => {
|
||||||
return json.success
|
if (!json.success) return uploadError(json.message || downMessage);
|
||||||
? dispatch({
|
if (cb) {
|
||||||
|
cb(json.data.serveUrl);
|
||||||
|
}
|
||||||
|
return dispatch({
|
||||||
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
||||||
thumbnail: json.data.serveUrl,
|
thumbnail: json.data.serveUrl,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
: uploadError(json.message || downMessage);
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
let message = err.message;
|
let message = err.message;
|
||||||
|
|
|
@ -14,6 +14,7 @@ type SharedData = {
|
||||||
app_welcome_version?: number,
|
app_welcome_version?: number,
|
||||||
sharing_3P?: boolean,
|
sharing_3P?: boolean,
|
||||||
unpublishedCollections: CollectionGroup,
|
unpublishedCollections: CollectionGroup,
|
||||||
|
editedCollections: CollectionGroup,
|
||||||
builtinCollections: CollectionGroup,
|
builtinCollections: CollectionGroup,
|
||||||
savedCollections: Array<string>,
|
savedCollections: Array<string>,
|
||||||
},
|
},
|
||||||
|
@ -31,6 +32,7 @@ function extractUserState(rawObj: SharedData) {
|
||||||
app_welcome_version,
|
app_welcome_version,
|
||||||
sharing_3P,
|
sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
} = rawObj.value;
|
} = rawObj.value;
|
||||||
|
@ -45,6 +47,7 @@ function extractUserState(rawObj: SharedData) {
|
||||||
...(app_welcome_version ? { app_welcome_version } : {}),
|
...(app_welcome_version ? { app_welcome_version } : {}),
|
||||||
...(sharing_3P ? { sharing_3P } : {}),
|
...(sharing_3P ? { sharing_3P } : {}),
|
||||||
...(unpublishedCollections ? { unpublishedCollections } : {}),
|
...(unpublishedCollections ? { unpublishedCollections } : {}),
|
||||||
|
...(editedCollections ? { editedCollections } : {}),
|
||||||
...(builtinCollections ? { builtinCollections } : {}),
|
...(builtinCollections ? { builtinCollections } : {}),
|
||||||
...(savedCollections ? { savedCollections } : {}),
|
...(savedCollections ? { savedCollections } : {}),
|
||||||
};
|
};
|
||||||
|
@ -65,6 +68,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
||||||
app_welcome_version,
|
app_welcome_version,
|
||||||
sharing_3P,
|
sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
} = extractUserState(sharedSettings);
|
} = extractUserState(sharedSettings);
|
||||||
|
@ -80,6 +84,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
||||||
welcomeVersion: app_welcome_version,
|
welcomeVersion: app_welcome_version,
|
||||||
allowAnalytics: sharing_3P,
|
allowAnalytics: sharing_3P,
|
||||||
unpublishedCollections,
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
builtinCollections,
|
builtinCollections,
|
||||||
savedCollections,
|
savedCollections,
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,8 +17,8 @@ type State = {
|
||||||
channelClaimCounts: { [string]: number },
|
channelClaimCounts: { [string]: number },
|
||||||
claimsByUri: { [string]: string },
|
claimsByUri: { [string]: string },
|
||||||
byId: { [string]: Claim },
|
byId: { [string]: Claim },
|
||||||
|
pendingById: { [string]: Claim }, // keep pending claims
|
||||||
resolvingUris: Array<string>,
|
resolvingUris: Array<string>,
|
||||||
pendingIds: Array<string>,
|
|
||||||
reflectingById: { [string]: ReflectingUpdate },
|
reflectingById: { [string]: ReflectingUpdate },
|
||||||
myClaims: ?Array<string>,
|
myClaims: ?Array<string>,
|
||||||
myChannelClaims: ?Array<string>,
|
myChannelClaims: ?Array<string>,
|
||||||
|
@ -83,7 +83,7 @@ const defaultState = {
|
||||||
fetchingMyChannels: false,
|
fetchingMyChannels: false,
|
||||||
fetchingMyCollections: false,
|
fetchingMyCollections: false,
|
||||||
abandoningById: {},
|
abandoningById: {},
|
||||||
pendingIds: [],
|
pendingById: {},
|
||||||
reflectingById: {},
|
reflectingById: {},
|
||||||
claimSearchError: false,
|
claimSearchError: false,
|
||||||
claimSearchByQuery: {},
|
claimSearchByQuery: {},
|
||||||
|
@ -117,7 +117,7 @@ function handleClaimAction(state: State, action: any): State {
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||||
const pendingIds = state.pendingIds;
|
const pendingById = state.pendingById;
|
||||||
let newResolvingUrls = new Set(state.resolvingUris);
|
let newResolvingUrls = new Set(state.resolvingUris);
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ function handleClaimAction(state: State, action: any): State {
|
||||||
const channel = channelFromResolve || (stream && stream.signing_channel);
|
const channel = channelFromResolve || (stream && stream.signing_channel);
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
if (pendingIds.includes(stream.claim_id)) {
|
if (pendingById[stream.claim_id]) {
|
||||||
byId[stream.claim_id] = mergeClaim(stream, byId[stream.claim_id]);
|
byId[stream.claim_id] = mergeClaim(stream, byId[stream.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[stream.claim_id] = stream;
|
byId[stream.claim_id] = stream;
|
||||||
|
@ -157,7 +157,7 @@ function handleClaimAction(state: State, action: any): State {
|
||||||
channelClaimCounts[channel.canonical_url] = claimsInChannel;
|
channelClaimCounts[channel.canonical_url] = claimsInChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pendingIds.includes(channel.claim_id)) {
|
if (pendingById[channel.claim_id]) {
|
||||||
byId[channel.claim_id] = mergeClaim(channel, byId[channel.claim_id]);
|
byId[channel.claim_id] = mergeClaim(channel, byId[channel.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[channel.claim_id] = channel;
|
byId[channel.claim_id] = channel;
|
||||||
|
@ -170,7 +170,7 @@ function handleClaimAction(state: State, action: any): State {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collection) {
|
if (collection) {
|
||||||
if (pendingIds.includes(collection.claim_id)) {
|
if (pendingById[collection.claim_id]) {
|
||||||
byId[collection.claim_id] = mergeClaim(collection, byId[collection.claim_id]);
|
byId[collection.claim_id] = mergeClaim(collection, byId[collection.claim_id]);
|
||||||
} else {
|
} else {
|
||||||
byId[collection.claim_id] = collection;
|
byId[collection.claim_id] = collection;
|
||||||
|
@ -187,7 +187,7 @@ function handleClaimAction(state: State, action: any): State {
|
||||||
}
|
}
|
||||||
|
|
||||||
newResolvingUrls.delete(url);
|
newResolvingUrls.delete(url);
|
||||||
if (!stream && !channel && !collection && !pendingIds.includes(byUri[url])) {
|
if (!stream && !channel && !collection && !pendingById[byUri[url]]) {
|
||||||
byUri[url] = null;
|
byUri[url] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -230,34 +230,33 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state: State): State =>
|
||||||
});
|
});
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): State => {
|
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): State => {
|
||||||
const { result, resolve }: { result: ClaimListResponse, resolve: boolean } = action.data;
|
const { result }: { result: ClaimListResponse } = action.data;
|
||||||
const claims = result.items;
|
const claims = result.items;
|
||||||
const page = result.page;
|
const page = result.page;
|
||||||
const totalItems = result.total_items;
|
const totalItems = result.total_items;
|
||||||
|
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
let urlsForCurrentPage = [];
|
let urlsForCurrentPage = [];
|
||||||
|
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
|
|
||||||
claims.forEach((claim: Claim) => {
|
claims.forEach((claim: Claim) => {
|
||||||
const { permanent_url: permanentUri, claim_id: claimId } = claim;
|
const { permanent_url: permanentUri, claim_id: claimId, canonical_url: canonicalUri } = claim;
|
||||||
if (claim.type && claim.type.match(/claim|update/)) {
|
if (claim.type && claim.type.match(/claim|update/)) {
|
||||||
urlsForCurrentPage.push(permanentUri);
|
urlsForCurrentPage.push(permanentUri);
|
||||||
if (claim.confirmations < 1) {
|
if (claim.confirmations < 1) {
|
||||||
pendingIdSet.add(claimId);
|
pendingById[claimId] = claim;
|
||||||
} else if (!resolve && pendingIdSet.has(claimId) && claim.confirmations > 0) {
|
if (byId[claimId]) {
|
||||||
pendingIdSet.delete(claimId);
|
|
||||||
}
|
|
||||||
if (pendingIds.includes(claimId)) {
|
|
||||||
byId[claimId] = mergeClaim(claim, byId[claimId]);
|
byId[claimId] = mergeClaim(claim, byId[claimId]);
|
||||||
} else {
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
byUri[permanentUri] = claimId;
|
byUri[permanentUri] = claimId;
|
||||||
|
byUri[canonicalUri] = claimId;
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -266,7 +265,7 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any):
|
||||||
isFetchingClaimListMine: false,
|
isFetchingClaimListMine: false,
|
||||||
myClaims: Array.from(myClaimIds),
|
myClaims: Array.from(myClaimIds),
|
||||||
byId,
|
byId,
|
||||||
pendingIds: Array.from(pendingIdSet),
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
myClaimsPageResults: urlsForCurrentPage,
|
myClaimsPageResults: urlsForCurrentPage,
|
||||||
myClaimsPageNumber: page,
|
myClaimsPageNumber: page,
|
||||||
|
@ -279,9 +278,8 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_STARTED] = (state: State): State =>
|
||||||
|
|
||||||
reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): State => {
|
reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): State => {
|
||||||
const { claims }: { claims: Array<ChannelClaim> } = action.data;
|
const { claims }: { claims: Array<ChannelClaim> } = action.data;
|
||||||
const myClaims = state.myClaims || [];
|
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myChannelClaims;
|
let myChannelClaims;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
|
@ -295,7 +293,12 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St
|
||||||
claims.forEach(claim => {
|
claims.forEach(claim => {
|
||||||
const { meta } = claim;
|
const { meta } = claim;
|
||||||
const { claims_in_channel: claimsInChannel } = claim.meta;
|
const { claims_in_channel: claimsInChannel } = claim.meta;
|
||||||
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
|
const {
|
||||||
|
canonical_url: canonicalUrl,
|
||||||
|
permanent_url: permanentUrl,
|
||||||
|
claim_id: claimId,
|
||||||
|
confirmations,
|
||||||
|
} = claim;
|
||||||
|
|
||||||
byUri[canonicalUrl] = claimId;
|
byUri[canonicalUrl] = claimId;
|
||||||
byUri[permanentUrl] = claimId;
|
byUri[permanentUrl] = claimId;
|
||||||
|
@ -304,7 +307,14 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
myChannelClaims.add(claimId);
|
myChannelClaims.add(claimId);
|
||||||
if (!pendingIds.some(c => c === claimId)) {
|
if (confirmations < 1) {
|
||||||
|
pendingById[claimId] = claim;
|
||||||
|
if (byId[claimId]) {
|
||||||
|
byId[claimId] = mergeClaim(claim, byId[claimId]);
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
|
@ -313,6 +323,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
channelClaimCounts,
|
channelClaimCounts,
|
||||||
fetchingMyChannels: false,
|
fetchingMyChannels: false,
|
||||||
|
@ -336,7 +347,7 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any):
|
||||||
const { claims }: { claims: Array<CollectionClaim> } = action.data;
|
const { claims }: { claims: Array<CollectionClaim> } = action.data;
|
||||||
const myClaims = state.myClaims || [];
|
const myClaims = state.myClaims || [];
|
||||||
let myClaimIds = new Set(myClaims);
|
let myClaimIds = new Set(myClaims);
|
||||||
const pendingIds = state.pendingIds || [];
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
let myCollectionClaimsSet = new Set([]);
|
let myCollectionClaimsSet = new Set([]);
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
|
@ -345,7 +356,12 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any):
|
||||||
myCollectionClaimsSet = new Set(state.myCollectionClaims);
|
myCollectionClaimsSet = new Set(state.myCollectionClaims);
|
||||||
claims.forEach(claim => {
|
claims.forEach(claim => {
|
||||||
const { meta } = claim;
|
const { meta } = claim;
|
||||||
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
|
const {
|
||||||
|
canonical_url: canonicalUrl,
|
||||||
|
permanent_url: permanentUrl,
|
||||||
|
claim_id: claimId,
|
||||||
|
confirmations,
|
||||||
|
} = claim;
|
||||||
|
|
||||||
byUri[canonicalUrl] = claimId;
|
byUri[canonicalUrl] = claimId;
|
||||||
byUri[permanentUrl] = claimId;
|
byUri[permanentUrl] = claimId;
|
||||||
|
@ -353,7 +369,14 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any):
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
myCollectionClaimsSet.add(claimId);
|
myCollectionClaimsSet.add(claimId);
|
||||||
// we don't want to overwrite a pending result with a resolve
|
// we don't want to overwrite a pending result with a resolve
|
||||||
if (!pendingIds.some(c => c === claimId)) {
|
if (confirmations < 1) {
|
||||||
|
pendingById[claimId] = claim;
|
||||||
|
if (byId[claimId]) {
|
||||||
|
byId[claimId] = mergeClaim(claim, byId[claimId]);
|
||||||
|
} else {
|
||||||
|
byId[claimId] = claim;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
byId[claimId] = claim;
|
byId[claimId] = claim;
|
||||||
}
|
}
|
||||||
myClaimIds.add(claimId);
|
myClaimIds.add(claimId);
|
||||||
|
@ -363,6 +386,7 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any):
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
fetchingMyCollections: false,
|
fetchingMyCollections: false,
|
||||||
myCollectionClaims: Array.from(myCollectionClaimsSet),
|
myCollectionClaims: Array.from(myCollectionClaimsSet),
|
||||||
|
@ -455,9 +479,8 @@ reducers[ACTIONS.ABANDON_CLAIM_STARTED] = (state: State, action: any): State =>
|
||||||
reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State => {
|
reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State => {
|
||||||
const { claims: pendingClaims }: { claims: Array<Claim> } = action.data;
|
const { claims: pendingClaims }: { claims: Array<Claim> } = action.data;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
|
const pendingById = Object.assign({}, state.pendingById);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds;
|
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
let myClaimIds = new Set(state.myClaims);
|
let myClaimIds = new Set(state.myClaims);
|
||||||
const myChannelClaims = new Set(state.myChannelClaims);
|
const myChannelClaims = new Set(state.myChannelClaims);
|
||||||
|
|
||||||
|
@ -465,7 +488,7 @@ reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State =>
|
||||||
pendingClaims.forEach((claim: Claim) => {
|
pendingClaims.forEach((claim: Claim) => {
|
||||||
let newClaim;
|
let newClaim;
|
||||||
const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim;
|
const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim;
|
||||||
pendingIdSet.add(claimId);
|
pendingById[claimId] = claim; // make sure we don't need to merge?
|
||||||
const oldClaim = byId[claimId];
|
const oldClaim = byId[claimId];
|
||||||
if (oldClaim && oldClaim.canonical_url) {
|
if (oldClaim && oldClaim.canonical_url) {
|
||||||
newClaim = mergeClaim(oldClaim, claim);
|
newClaim = mergeClaim(oldClaim, claim);
|
||||||
|
@ -485,21 +508,22 @@ reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State =>
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
myClaims: Array.from(myClaimIds),
|
myClaims: Array.from(myClaimIds),
|
||||||
byId,
|
byId,
|
||||||
|
pendingById,
|
||||||
myChannelClaims: Array.from(myChannelClaims),
|
myChannelClaims: Array.from(myChannelClaims),
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
pendingIds: Array.from(pendingIdSet),
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[ACTIONS.UPDATE_CONFIRMED_CLAIMS] = (state: State, action: any): State => {
|
reducers[ACTIONS.UPDATE_CONFIRMED_CLAIMS] = (state: State, action: any): State => {
|
||||||
const { claims: confirmedClaims }: { claims: Array<Claim> } = action.data;
|
const {
|
||||||
|
claims: confirmedClaims,
|
||||||
|
pending: pendingClaims,
|
||||||
|
}: { claims: Array<Claim>, pending: { [string]: Claim } } = action.data;
|
||||||
const byId = Object.assign({}, state.byId);
|
const byId = Object.assign({}, state.byId);
|
||||||
const byUri = Object.assign({}, state.claimsByUri);
|
const byUri = Object.assign({}, state.claimsByUri);
|
||||||
const pendingIds = state.pendingIds;
|
//
|
||||||
const pendingIdSet = new Set(pendingIds);
|
|
||||||
|
|
||||||
confirmedClaims.forEach((claim: GenericClaim) => {
|
confirmedClaims.forEach((claim: GenericClaim) => {
|
||||||
const { permanent_url: permanentUri, claim_id: claimId, type } = claim;
|
const { claim_id: claimId, type } = claim;
|
||||||
let newClaim = claim;
|
let newClaim = claim;
|
||||||
const oldClaim = byId[claimId];
|
const oldClaim = byId[claimId];
|
||||||
if (oldClaim && oldClaim.canonical_url) {
|
if (oldClaim && oldClaim.canonical_url) {
|
||||||
|
@ -507,11 +531,10 @@ reducers[ACTIONS.UPDATE_CONFIRMED_CLAIMS] = (state: State, action: any): State =
|
||||||
}
|
}
|
||||||
if (type && type.match(/claim|update|channel/)) {
|
if (type && type.match(/claim|update|channel/)) {
|
||||||
byId[claimId] = newClaim;
|
byId[claimId] = newClaim;
|
||||||
pendingIdSet.delete(claimId);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
pendingIds: Array.from(pendingIdSet),
|
pendingById: pendingClaims,
|
||||||
byId,
|
byId,
|
||||||
claimsByUri: byUri,
|
claimsByUri: byUri,
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,8 +90,15 @@ const collectionsReducer = handleActions(
|
||||||
|
|
||||||
[ACTIONS.COLLECTION_PENDING]: (state, action) => {
|
[ACTIONS.COLLECTION_PENDING]: (state, action) => {
|
||||||
const { localId, claimId } = action.data;
|
const { localId, claimId } = action.data;
|
||||||
const { edited: editList, unpublished: unpublishedList, pending: pendingList } = state;
|
const {
|
||||||
|
resolved: resolvedList,
|
||||||
|
edited: editList,
|
||||||
|
unpublished: unpublishedList,
|
||||||
|
pending: pendingList,
|
||||||
|
} = state;
|
||||||
|
|
||||||
const newEditList = Object.assign({}, editList);
|
const newEditList = Object.assign({}, editList);
|
||||||
|
const newResolvedList = Object.assign({}, resolvedList);
|
||||||
const newUnpublishedList = Object.assign({}, unpublishedList);
|
const newUnpublishedList = Object.assign({}, unpublishedList);
|
||||||
const newPendingList = Object.assign({}, pendingList);
|
const newPendingList = Object.assign({}, pendingList);
|
||||||
|
|
||||||
|
@ -101,7 +108,10 @@ const collectionsReducer = handleActions(
|
||||||
delete newUnpublishedList[localId];
|
delete newUnpublishedList[localId];
|
||||||
} else {
|
} else {
|
||||||
// edit update
|
// edit update
|
||||||
newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
|
newPendingList[claimId] = Object.assign(
|
||||||
|
{},
|
||||||
|
newEditList[claimId] || newResolvedList[claimId]
|
||||||
|
);
|
||||||
delete newEditList[claimId];
|
delete newEditList[claimId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +168,15 @@ const collectionsReducer = handleActions(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[ACTIONS.USER_STATE_POPULATE]: (state, action) => {
|
[ACTIONS.USER_STATE_POPULATE]: (state, action) => {
|
||||||
const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
|
const {
|
||||||
|
builtinCollections,
|
||||||
|
savedCollections,
|
||||||
|
unpublishedCollections,
|
||||||
|
editedCollections,
|
||||||
|
} = action.data;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
edited: editedCollections || state.edited,
|
||||||
unpublished: unpublishedCollections || state.unpublished,
|
unpublished: unpublishedCollections || state.unpublished,
|
||||||
builtin: builtinCollections || state.builtin,
|
builtin: builtinCollections || state.builtin,
|
||||||
saved: savedCollections || state.saved,
|
saved: savedCollections || state.saved,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { normalizeURI, buildURI, parseURI } from 'lbryURI';
|
import { normalizeURI, parseURI } from 'lbryURI';
|
||||||
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { isClaimNsfw, filterClaims } from 'util/claim';
|
import { isClaimNsfw, filterClaims } from 'util/claim';
|
||||||
|
@ -7,11 +7,24 @@ import * as CLAIM from 'constants/claim';
|
||||||
|
|
||||||
const selectState = state => state.claims || {};
|
const selectState = state => state.claims || {};
|
||||||
|
|
||||||
export const selectClaimsById = createSelector(
|
export const selectById = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.byId || {}
|
state => state.byId || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectPendingClaimsById = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.pendingById || {}
|
||||||
|
);
|
||||||
|
|
||||||
|
export const selectClaimsById = createSelector(
|
||||||
|
selectById,
|
||||||
|
selectPendingClaimsById,
|
||||||
|
(byId, pendingById) => {
|
||||||
|
return Object.assign(byId, pendingById); // do I need merged to keep metadata?
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const selectClaimIdsByUri = createSelector(
|
export const selectClaimIdsByUri = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.claimsByUri || {}
|
state => state.claimsByUri || {}
|
||||||
|
@ -72,33 +85,33 @@ export const selectAllClaimsByChannel = createSelector(
|
||||||
|
|
||||||
export const selectPendingIds = createSelector(
|
export const selectPendingIds = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.pendingIds || []
|
state => Object.keys(state.pendingById) || []
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectPendingClaims = createSelector(
|
export const selectPendingClaims = createSelector(
|
||||||
selectPendingIds,
|
selectPendingClaimsById,
|
||||||
selectClaimsById,
|
pendingById => Object.values(pendingById)
|
||||||
(pendingIds, byId) => pendingIds.map(id => byId[id])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectClaimIsPending = (uri: string) =>
|
export const makeSelectClaimIsPending = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimIdsByUri,
|
selectClaimIdsByUri,
|
||||||
selectPendingIds,
|
selectPendingClaimsById,
|
||||||
(idsByUri, pendingIds) => {
|
(idsByUri, pendingById) => {
|
||||||
const claimId = idsByUri[normalizeURI(uri)];
|
const claimId = idsByUri[normalizeURI(uri)];
|
||||||
|
|
||||||
if (claimId) {
|
if (claimId) {
|
||||||
return pendingIds.some(i => i === claimId);
|
return Boolean(pendingById[claimId]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectClaimIdIsPending = (claimId: string) => createSelector(
|
export const makeSelectClaimIdIsPending = (claimId: string) =>
|
||||||
selectPendingIds,
|
createSelector(
|
||||||
(pendingIds) => {
|
selectPendingClaimsById,
|
||||||
return pendingIds.some(i => i === claimId);
|
pendingById => {
|
||||||
|
return Boolean(pendingById[claimId]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -152,7 +165,7 @@ export const makeSelectClaimForUri = (uri: string, returnRepost: boolean = true)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...repostedClaim,
|
...repostedClaim,
|
||||||
repost_url: uri,
|
repost_url: normalizeURI(uri),
|
||||||
repost_channel_url: channelUrl,
|
repost_channel_url: channelUrl,
|
||||||
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount,
|
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount,
|
||||||
};
|
};
|
||||||
|
@ -325,6 +338,7 @@ export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// THIS IS LEFT OVER FROM ONE TAB CHANNEL_CONTENT
|
||||||
export const makeSelectTotalClaimsInChannelSearch = (uri: string) =>
|
export const makeSelectTotalClaimsInChannelSearch = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
|
@ -335,6 +349,7 @@ export const makeSelectTotalClaimsInChannelSearch = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// THIS IS LEFT OVER FROM ONE_TAB CHANNEL CONTENT
|
||||||
export const makeSelectTotalPagesInChannelSearch = (uri: string) =>
|
export const makeSelectTotalPagesInChannelSearch = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
|
@ -345,21 +360,6 @@ export const makeSelectTotalPagesInChannelSearch = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectClaimsInChannelForCurrentPageState = (uri: string) =>
|
|
||||||
createSelector(
|
|
||||||
selectClaimsById,
|
|
||||||
selectAllClaimsByChannel,
|
|
||||||
selectCurrentChannelPage,
|
|
||||||
(byId, allClaims, page) => {
|
|
||||||
const byChannel = allClaims[uri] || {};
|
|
||||||
const claimIds = byChannel[page || 1];
|
|
||||||
|
|
||||||
if (!claimIds) return claimIds;
|
|
||||||
|
|
||||||
return claimIds.map(claimId => byId[claimId]);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const makeSelectMetadataForUri = (uri: string) =>
|
export const makeSelectMetadataForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
|
@ -500,7 +500,9 @@ export const selectMyClaims = createSelector(
|
||||||
export const selectMyClaimsWithoutChannels = createSelector(
|
export const selectMyClaimsWithoutChannels = createSelector(
|
||||||
selectMyClaims,
|
selectMyClaims,
|
||||||
myClaims =>
|
myClaims =>
|
||||||
myClaims.filter(claim => claim && !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp)
|
myClaims
|
||||||
|
.filter(claim => claim && !claim.name.match(/^@/))
|
||||||
|
.sort((a, b) => a.timestamp - b.timestamp)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectMyClaimUrisWithoutChannels = createSelector(
|
export const selectMyClaimUrisWithoutChannels = createSelector(
|
||||||
|
@ -608,31 +610,18 @@ export const selectChannelClaimCounts = createSelector(
|
||||||
|
|
||||||
export const makeSelectPendingClaimForUri = (uri: string) =>
|
export const makeSelectPendingClaimForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectPendingIds,
|
selectPendingClaimsById,
|
||||||
selectClaimsById,
|
pendingById => {
|
||||||
(pending, claims) => {
|
|
||||||
let validUri;
|
|
||||||
let uriIsChannel;
|
|
||||||
let uriStreamName;
|
let uriStreamName;
|
||||||
let uriChannelName;
|
let uriChannelName;
|
||||||
try {
|
try {
|
||||||
({
|
({ streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri));
|
||||||
isChannel: uriIsChannel,
|
|
||||||
streamName: uriStreamName,
|
|
||||||
channelName: uriChannelName,
|
|
||||||
} = parseURI(uri));
|
|
||||||
validUri = true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const pendingClaims = pending.map(id => claims[id]);
|
const pendingClaims = (Object.values(pendingById): any);
|
||||||
const matchingClaim = pendingClaims.find(claim => {
|
const matchingClaim = pendingClaims.find((claim: GenericClaim) => {
|
||||||
const { streamName, channelName, isChannel } = parseURI(claim.permanent_url);
|
return claim.normalized_name === uriChannelName || claim.normalized_name === uriStreamName;
|
||||||
if (isChannel) {
|
|
||||||
return channelName === uriChannelName;
|
|
||||||
} else {
|
|
||||||
return streamName === uriStreamName;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return matchingClaim || null;
|
return matchingClaim || null;
|
||||||
}
|
}
|
||||||
|
@ -641,13 +630,13 @@ export const makeSelectPendingClaimForUri = (uri: string) =>
|
||||||
export const makeSelectTotalItemsForChannel = (uri: string) =>
|
export const makeSelectTotalItemsForChannel = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectChannelClaimCounts,
|
selectChannelClaimCounts,
|
||||||
byUri => byUri && byUri[uri]
|
byUri => byUri && byUri[normalizeURI(uri)]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectTotalPagesForChannel = (uri: string, pageSize: number = 10) =>
|
export const makeSelectTotalPagesForChannel = (uri: string, pageSize: number = 10) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectChannelClaimCounts,
|
selectChannelClaimCounts,
|
||||||
byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)
|
byUri => byUri && byUri[uri] && Math.ceil(byUri[normalizeURI(uri)] / pageSize)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectNsfwCountFromUris = (uris: Array<string>) =>
|
export const makeSelectNsfwCountFromUris = (uris: Array<string>) =>
|
||||||
|
@ -663,27 +652,6 @@ export const makeSelectNsfwCountFromUris = (uris: Array<string>) =>
|
||||||
}, 0)
|
}, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectNsfwCountForChannel = (uri: string) =>
|
|
||||||
createSelector(
|
|
||||||
selectClaimsById,
|
|
||||||
selectAllClaimsByChannel,
|
|
||||||
selectCurrentChannelPage,
|
|
||||||
(byId, allClaims, page) => {
|
|
||||||
const byChannel = allClaims[uri] || {};
|
|
||||||
const claimIds = byChannel[page || 1];
|
|
||||||
|
|
||||||
if (!claimIds) return 0;
|
|
||||||
|
|
||||||
return claimIds.reduce((acc, claimId) => {
|
|
||||||
const claim = byId[claimId];
|
|
||||||
if (isClaimNsfw(claim)) {
|
|
||||||
return acc + 1;
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const makeSelectOmittedCountForChannel = (uri: string) =>
|
export const makeSelectOmittedCountForChannel = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectTotalItemsForChannel(uri),
|
makeSelectTotalItemsForChannel(uri),
|
||||||
|
@ -763,14 +731,6 @@ export const makeSelectTagsForUri = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const makeSelectChannelTagsForUri = (uri: string) =>
|
|
||||||
createSelector(
|
|
||||||
makeSelectMetadataForUri(uri),
|
|
||||||
(metadata: ?GenericMetadata) => {
|
|
||||||
return (metadata && metadata.tags) || [];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const selectFetchingClaimSearchByQuery = createSelector(
|
export const selectFetchingClaimSearchByQuery = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.fetchingClaimSearchByQuery || {}
|
state => state.fetchingClaimSearchByQuery || {}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
import fromEntries from '@ungap/from-entries';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import {
|
import {
|
||||||
selectMyCollectionIds,
|
selectMyCollectionIds,
|
||||||
|
@ -79,7 +80,7 @@ export const selectMyPublishedCollections = createSelector(
|
||||||
selectMyCollectionIds,
|
selectMyCollectionIds,
|
||||||
(resolved, pending, edited, myIds) => {
|
(resolved, pending, edited, myIds) => {
|
||||||
// all resolved in myIds, plus those in pending and edited
|
// all resolved in myIds, plus those in pending and edited
|
||||||
const myPublishedCollections = Object.fromEntries(
|
const myPublishedCollections = fromEntries(
|
||||||
Object.entries(pending).concat(
|
Object.entries(pending).concat(
|
||||||
Object.entries(resolved).filter(
|
Object.entries(resolved).filter(
|
||||||
([key, val]) =>
|
([key, val]) =>
|
||||||
|
@ -100,7 +101,7 @@ export const selectMyPublishedCollections = createSelector(
|
||||||
export const selectMyPublishedMixedCollections = createSelector(
|
export const selectMyPublishedMixedCollections = createSelector(
|
||||||
selectMyPublishedCollections,
|
selectMyPublishedCollections,
|
||||||
published => {
|
published => {
|
||||||
const myCollections = Object.fromEntries(
|
const myCollections = fromEntries(
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(published).filter(([key, collection]) => {
|
Object.entries(published).filter(([key, collection]) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -114,7 +115,7 @@ export const selectMyPublishedMixedCollections = createSelector(
|
||||||
export const selectMyPublishedPlaylistCollections = createSelector(
|
export const selectMyPublishedPlaylistCollections = createSelector(
|
||||||
selectMyPublishedCollections,
|
selectMyPublishedCollections,
|
||||||
published => {
|
published => {
|
||||||
const myCollections = Object.fromEntries(
|
const myCollections = fromEntries(
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
Object.entries(published).filter(([key, collection]) => {
|
Object.entries(published).filter(([key, collection]) => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -135,7 +136,7 @@ export const makeSelectMyPublishedCollectionForId = (id: string) =>
|
||||||
// selectResolvedCollections,
|
// selectResolvedCollections,
|
||||||
// selectSavedCollectionIds,
|
// selectSavedCollectionIds,
|
||||||
// (resolved, myIds) => {
|
// (resolved, myIds) => {
|
||||||
// const mySavedCollections = Object.fromEntries(
|
// const mySavedCollections = fromEntries(
|
||||||
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
||||||
// );
|
// );
|
||||||
// return mySavedCollections;
|
// return mySavedCollections;
|
||||||
|
@ -158,11 +159,33 @@ export const makeSelectCollectionForId = (id: string) =>
|
||||||
selectMyEditedCollections,
|
selectMyEditedCollections,
|
||||||
selectPendingCollections,
|
selectPendingCollections,
|
||||||
(bLists, rLists, uLists, eLists, pLists) => {
|
(bLists, rLists, uLists, eLists, pLists) => {
|
||||||
const collection = bLists[id] || uLists[id] || eLists[id] || rLists[id] || pLists[id];
|
const collection = bLists[id] || uLists[id] || eLists[id] || pLists[id] || rLists[id];
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectClaimUrlInCollection = (url: string) =>
|
||||||
|
createSelector(
|
||||||
|
selectBuiltinCollections,
|
||||||
|
selectMyPublishedCollections,
|
||||||
|
selectMyUnpublishedCollections,
|
||||||
|
selectMyEditedCollections,
|
||||||
|
selectPendingCollections,
|
||||||
|
(bLists, myRLists, uLists, eLists, pLists) => {
|
||||||
|
const collections = [bLists, uLists, eLists, myRLists, pLists];
|
||||||
|
const itemsInCollections = [];
|
||||||
|
collections.map(list => {
|
||||||
|
Object.entries(list).forEach(([key, value]) => {
|
||||||
|
// $FlowFixMe
|
||||||
|
value.items.map(item => {
|
||||||
|
itemsInCollections.push(item);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return itemsInCollections.includes(url);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const makeSelectCollectionForIdHasClaimUrl = (id: string, url: string) =>
|
export const makeSelectCollectionForIdHasClaimUrl = (id: string, url: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectCollectionForId(id),
|
makeSelectCollectionForId(id),
|
||||||
|
@ -190,14 +213,18 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
||||||
|
|
||||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
state => state.content.shuffleList,
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
makeSelectClaimForUri(url),
|
makeSelectClaimForUri(url),
|
||||||
(urls, claim) => {
|
(shuffleState, urls, claim) => {
|
||||||
const index = urls && urls.findIndex(u => u === url);
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
|
||||||
|
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return index;
|
return index;
|
||||||
} else if (claim) {
|
} else if (claim) {
|
||||||
const index = urls && urls.findIndex(u => u === claim.permanent_url);
|
const index = listUrls && listUrls.findIndex(u => u === claim.permanent_url);
|
||||||
if (index > -1) return index;
|
if (index > -1) return index;
|
||||||
return claim;
|
return claim;
|
||||||
}
|
}
|
||||||
|
@ -205,20 +232,49 @@ export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectPreviousUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||||
|
createSelector(
|
||||||
|
state => state.content.shuffleList,
|
||||||
|
state => state.content.loopList,
|
||||||
|
makeSelectIndexForUrlInCollection(url, id),
|
||||||
|
makeSelectUrlsForCollectionId(id),
|
||||||
|
(shuffleState, loopState, index, urls) => {
|
||||||
|
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||||
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
|
||||||
|
if (index > -1) {
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
|
let nextUrl;
|
||||||
|
if (index === 0 && loopList) {
|
||||||
|
nextUrl = listUrls[listUrls.length - 1];
|
||||||
|
} else {
|
||||||
|
nextUrl = listUrls[index - 1];
|
||||||
|
}
|
||||||
|
return nextUrl || null;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
export const makeSelectNextUrlForCollectionAndUrl = (id: string, url: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
state => state.content.shuffleList,
|
||||||
|
state => state.content.loopList,
|
||||||
makeSelectIndexForUrlInCollection(url, id),
|
makeSelectIndexForUrlInCollection(url, id),
|
||||||
selectClaimsByUri,
|
|
||||||
makeSelectUrlsForCollectionId(id),
|
makeSelectUrlsForCollectionId(id),
|
||||||
(index, claims, urls) => {
|
(shuffleState, loopState, index, urls) => {
|
||||||
|
const loopList = loopState && loopState.collectionId === id && loopState.loop;
|
||||||
|
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
const listUrls = shuffleUrls || urls;
|
||||||
// We'll get the next playble url
|
// We'll get the next playble url
|
||||||
const remainingUrls = urls.slice(index + 1);
|
let remainingUrls = listUrls.slice(index + 1);
|
||||||
const nextUrl = remainingUrls.find(
|
if (!remainingUrls.length && loopList) {
|
||||||
u =>
|
remainingUrls = listUrls.slice(0);
|
||||||
claims[u].value.stream_type &&
|
}
|
||||||
(claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio')
|
const nextUrl = remainingUrls && remainingUrls[0];
|
||||||
);
|
|
||||||
return nextUrl || null;
|
return nextUrl || null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -242,7 +298,13 @@ export const makeSelectCountForCollectionId = (id: string) =>
|
||||||
if (collection.itemCount !== undefined) {
|
if (collection.itemCount !== undefined) {
|
||||||
return collection.itemCount;
|
return collection.itemCount;
|
||||||
}
|
}
|
||||||
return collection.items.length;
|
let itemCount = 0;
|
||||||
|
collection.items.map(item => {
|
||||||
|
if (item) {
|
||||||
|
itemCount += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return itemCount;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1411,6 +1411,11 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/yargs-parser" "*"
|
"@types/yargs-parser" "*"
|
||||||
|
|
||||||
|
"@ungap/from-entries@^0.2.1":
|
||||||
|
version "0.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@ungap/from-entries/-/from-entries-0.2.1.tgz#7e86196b8b2e99d73106a8f25c2a068326346354"
|
||||||
|
integrity sha512-CAqefTFAfnUPwYqsWHXpOxHaq1Zo5UQ3m9Zm2p09LggGe57rqHoBn3c++xcoomzXKynAUuiBMDUCQvKMnXjUpA==
|
||||||
|
|
||||||
abab@^1.0.4:
|
abab@^1.0.4:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
||||||
|
|
Loading…
Reference in a new issue