Compare commits

..

1 commit

Author SHA1 Message Date
zeppi
3bbc9aabca fix pending ids selector 2021-07-05 15:49:28 -04:00
16 changed files with 108 additions and 384 deletions

189
dist/bundle.es.js vendored
View file

@ -2,12 +2,9 @@
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;
@ -719,7 +716,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_MEDIA = 'autoplay'; const AUTOPLAY = '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';
@ -735,8 +732,6 @@ 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';
@ -770,7 +765,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_MEDIA: AUTOPLAY_MEDIA, AUTOPLAY: AUTOPLAY,
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,
@ -786,8 +781,6 @@ 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,
@ -1040,7 +1033,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_MEDIA, AUTOPLAY_NEXT, HIDE_BALANCE, HIDE_SPLASH_ANIMATION, FLOATING_PLAYER, DARK_MODE_TIMES, AUTOMATIC_DARK_MODE_ENABLED, LANGUAGE]; 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];
var shared_preferences = /*#__PURE__*/Object.freeze({ var shared_preferences = /*#__PURE__*/Object.freeze({
SDK_SYNC_KEYS: SDK_SYNC_KEYS, SDK_SYNC_KEYS: SDK_SYNC_KEYS,
@ -1480,7 +1473,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 = '([^:$#/]*)';
@ -1488,11 +1481,6 @@ 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.
@ -1594,11 +1582,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 === MOD_CLAIM_ID_SEPARATOR || MOD_CLAIM_ID_SEPARATOR_OLD) { if (modSeperator === '#') {
claimId = modValue; claimId = modValue;
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) { } else if (modSeperator === ':') {
claimSequence = modValue; claimSequence = modValue;
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) { } else if (modSeperator === '$') {
bidPosition = modValue; bidPosition = modValue;
} }
} }
@ -1729,25 +1717,6 @@ 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
@ -1871,12 +1840,11 @@ 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 } : {}, editedCollections ? { editedCollections } : {}, 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 } : {}, builtinCollections ? { builtinCollections } : {}, savedCollections ? { savedCollections } : {});
} }
return {}; return {};
@ -1894,7 +1862,6 @@ function doPopulateSharedUserState(sharedSettings) {
app_welcome_version, app_welcome_version,
sharing_3P, sharing_3P,
unpublishedCollections, unpublishedCollections,
editedCollections,
builtinCollections, builtinCollections,
savedCollections savedCollections
} = extractUserState(sharedSettings); } = extractUserState(sharedSettings);
@ -1910,7 +1877,6 @@ function doPopulateSharedUserState(sharedSettings) {
welcomeVersion: app_welcome_version, welcomeVersion: app_welcome_version,
allowAnalytics: sharing_3P, allowAnalytics: sharing_3P,
unpublishedCollections, unpublishedCollections,
editedCollections,
builtinCollections, builtinCollections,
savedCollections savedCollections
} }
@ -2495,7 +2461,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: normalizeURI(uri), repost_url: 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
}); });
@ -2746,9 +2712,9 @@ const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendin
return matchingClaim || null; return matchingClaim || null;
}); });
const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[normalizeURI(uri)]); const makeSelectTotalItemsForChannel = uri => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[normalizeURI(uri)] / pageSize)); const makeSelectTotalPagesForChannel = (uri, pageSize = 10) => reselect.createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri] && Math.ceil(byUri[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];
@ -3651,7 +3617,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 = fromEntries(Object.entries(pending).concat(Object.entries(resolved).filter(([key, val]) => myIds.includes(key) && const myPublishedCollections = Object.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:
@ -3662,7 +3628,7 @@ const selectMyPublishedCollections = reselect.createSelector(selectResolvedColle
}); });
const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => { const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => {
const myCollections = fromEntries( const myCollections = Object.fromEntries(
// $FlowFixMe // $FlowFixMe
Object.entries(published).filter(([key, collection]) => { Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe // $FlowFixMe
@ -3672,7 +3638,7 @@ const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublis
}); });
const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => { const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => {
const myCollections = fromEntries( const myCollections = Object.fromEntries(
// $FlowFixMe // $FlowFixMe
Object.entries(published).filter(([key, collection]) => { Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe // $FlowFixMe
@ -3687,7 +3653,7 @@ const makeSelectMyPublishedCollectionForId = id => reselect.createSelector(selec
// selectResolvedCollections, // selectResolvedCollections,
// selectSavedCollectionIds, // selectSavedCollectionIds,
// (resolved, myIds) => { // (resolved, myIds) => {
// const mySavedCollections = fromEntries( // const mySavedCollections = Object.fromEntries(
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key)) // Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
// ); // );
// return mySavedCollections; // return mySavedCollections;
@ -3703,20 +3669,6 @@ const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCol
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);
@ -3730,51 +3682,23 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
return ids; return ids;
}); });
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(state => state.content.shuffleList, makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (shuffleState, urls, claim) => { const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls; const index = urls && urls.findIndex(u => u === url);
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 = listUrls && listUrls.findIndex(u => u === claim.permanent_url); const index = urls && urls.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 makeSelectPreviousUrlForCollectionAndUrl = (id, url) => reselect.createSelector(state => state.content.shuffleList, state => state.content.loopList, makeSelectIndexForUrlInCollection(url, id), makeSelectUrlsForCollectionId(id), (shuffleState, loopState, index, urls) => { const makeSelectNextUrlForCollectionAndUrl = (id, url) => reselect.createSelector(makeSelectIndexForUrlInCollection(url, id), selectClaimsByUri, makeSelectUrlsForCollectionId(id), (index, claims, 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
let remainingUrls = listUrls.slice(index + 1); const remainingUrls = urls.slice(index + 1);
if (!remainingUrls.length && loopList) { const nextUrl = remainingUrls.find(u => claims[u].value.stream_type && (claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio'));
remainingUrls = listUrls.slice(0);
}
const nextUrl = remainingUrls && remainingUrls[0];
return nextUrl || null; return nextUrl || null;
} else { } else {
return null; return null;
@ -3790,13 +3714,7 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
if (collection.itemCount !== undefined) { if (collection.itemCount !== undefined) {
return collection.itemCount; return collection.itemCount;
} }
let itemCount = 0; return collection.items.length;
collection.items.map(item => {
if (item) {
itemCount += 1;
}
});
return itemCount;
} }
return null; return null;
}); });
@ -4502,15 +4420,11 @@ function doCollectionPublish(options, localId) {
}; };
} }
function doCollectionPublishUpdate(options, isBackgroundUpdate) { function doCollectionPublishUpdate(options) {
return (dispatch, getState) => { return dispatch => {
// TODO: implement one click update // TODO: implement one click update
const updateParams = isBackgroundUpdate ? { const updateParams = {
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,
@ -4520,25 +4434,16 @@ function doCollectionPublishUpdate(options, isBackgroundUpdate) {
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.channel_id) { if (options.claims) {
updateParams['channel_id'] = options.channel_id; updateParams['claims'] = options.claims;
} }
return new Promise(resolve => { return new Promise(resolve => {
dispatch({ dispatch({
type: COLLECTION_PUBLISH_UPDATE_STARTED type: COLLECTION_PUBLISH_UPDATE_STARTED
@ -4708,7 +4613,7 @@ const getTimestamp = () => {
return Math.floor(Date.now() / 1000); return Math.floor(Date.now() / 1000);
}; };
const FETCH_BATCH_SIZE = 50; const FETCH_BATCH_SIZE = 10;
const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => { const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => {
return dispatch({ return dispatch({
@ -4815,8 +4720,7 @@ 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);
@ -5633,7 +5537,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
data: _extends$7({}, publishFormValue) data: _extends$7({}, publishFormValue)
}); });
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) => dispatch => { const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => 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;
@ -5667,17 +5571,13 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) =>
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 => {
if (!json.success) return uploadError(json.message || downMessage); return json.success ? dispatch({
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;
@ -7772,15 +7672,8 @@ const collectionsReducer = handleActions({
[COLLECTION_PENDING]: (state, action) => { [COLLECTION_PENDING]: (state, action) => {
const { localId, claimId } = action.data; const { localId, claimId } = action.data;
const { const { edited: editList, unpublished: unpublishedList, pending: pendingList } = state;
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);
@ -7790,7 +7683,7 @@ const collectionsReducer = handleActions({
delete newUnpublishedList[localId]; delete newUnpublishedList[localId];
} else { } else {
// edit update // edit update
newPendingList[claimId] = Object.assign({}, newEditList[claimId] || newResolvedList[claimId]); newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
delete newEditList[claimId]; delete newEditList[claimId];
} }
@ -7842,14 +7735,8 @@ const collectionsReducer = handleActions({
})); }));
}, },
[USER_STATE_POPULATE]: (state, action) => { [USER_STATE_POPULATE]: (state, action) => {
const { const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
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
@ -8049,7 +7936,6 @@ 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;
@ -8066,7 +7952,6 @@ 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.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage; exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
exports.makeSelectCollectionForId = makeSelectCollectionForId; exports.makeSelectCollectionForId = makeSelectCollectionForId;
@ -8107,7 +7992,6 @@ 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;
@ -8267,6 +8151,5 @@ 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;

View file

@ -1,5 +0,0 @@
// @flow
declare module '@ungap/from-entries' {
declare module.exports: any;
}

View file

@ -1,5 +0,0 @@
// @flow
declare module '@ungap/from-entries' {
declare module.exports: any;
}

View file

@ -29,7 +29,6 @@
"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"

View file

@ -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_MEDIA = 'autoplay'; export const AUTOPLAY = '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,8 +39,6 @@ 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';

View file

@ -21,12 +21,10 @@ 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_MEDIA, SETTINGS.AUTOPLAY,
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,
]; ];

View file

@ -52,8 +52,6 @@ export {
isURIClaimable, isURIClaimable,
isNameValid, isNameValid,
convertToShareLink, convertToShareLink,
splitBySeparator,
isURIEqual,
} from 'lbryURI'; } from 'lbryURI';
// middlware // middlware
@ -176,14 +174,12 @@ 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';

View file

@ -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,11 +12,6 @@ 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.
@ -149,11 +144,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 === MOD_CLAIM_ID_SEPARATOR || MOD_CLAIM_ID_SEPARATOR_OLD) { if (modSeperator === '#') {
claimId = modValue; claimId = modValue;
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) { } else if (modSeperator === ':') {
claimSequence = modValue; claimSequence = modValue;
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) { } else if (modSeperator === '$') {
bidPosition = modValue; bidPosition = modValue;
} }
} }
@ -325,22 +320,3 @@ 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;
}
}

View file

@ -19,10 +19,7 @@ import { creditsToString } from 'util/format-credits';
import { batchActions } from 'util/batch-actions'; import { batchActions } from 'util/batch-actions';
import { createNormalizedClaimSearchKey } from 'util/claim'; import { createNormalizedClaimSearchKey } from 'util/claim';
import { PAGE_SIZE } from 'constants/claim'; import { PAGE_SIZE } from 'constants/claim';
import { import { selectPendingCollections } from 'redux/selectors/collections';
selectPendingCollections,
makeSelectClaimIdsForCollectionId,
} from 'redux/selectors/collections';
import { import {
doFetchItemsInCollection, doFetchItemsInCollection,
doFetchItemsInCollections, doFetchItemsInCollections,
@ -831,22 +828,18 @@ export function doCollectionPublish(
}; };
} }
export function doCollectionPublishUpdate( export function doCollectionPublishUpdate(options: {
options: { bid?: string,
bid?: string, blocking?: true,
blocking?: true, title?: string,
title?: string, thumbnail_url?: string,
thumbnail_url?: string, description?: string,
description?: string, claim_id: string,
claim_id: string, 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: {
@ -854,49 +847,32 @@ export function doCollectionPublishUpdate(
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 bid: creditsToString(options.bid),
? { title: options.title,
blocking: true, thumbnail_url: options.thumbnail_url,
claim_id: options.claim_id, description: options.description,
clear_claims: true, tags: [],
} languages: options.languages || [],
: { locations: [],
bid: creditsToString(options.bid), blocking: true,
title: options.title, claim_id: options.claim_id,
thumbnail_url: options.thumbnail_url, clear_claims: true,
description: options.description, };
tags: [],
languages: options.languages || [],
locations: [],
blocking: true,
claim_id: options.claim_id,
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.channel_id) { if (options.claims) {
updateParams['channel_id'] = options.channel_id; updateParams['claims'] = options.claims;
} }
return new Promise(resolve => { return new Promise(resolve => {
dispatch({ dispatch({
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED, type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,

View file

@ -18,7 +18,7 @@ const getTimestamp = () => {
return Math.floor(Date.now() / 1000); return Math.floor(Date.now() / 1000);
}; };
const FETCH_BATCH_SIZE = 50; const FETCH_BATCH_SIZE = 10;
export const doLocalCollectionCreate = ( export const doLocalCollectionCreate = (
name: string, name: string,
@ -93,7 +93,7 @@ export const doFetchItemsInCollections = (
pageSize?: number, pageSize?: number,
}, },
resolveStartedCallback?: () => void resolveStartedCallback?: () => void
) => async(dispatch: Dispatch, getState: GetState) => { ) => async (dispatch: Dispatch, getState: GetState) => {
/* /*
1) make sure all the collection claims are loaded into claims reducer, search/resolve if necessary. 1) make sure all the collection claims are loaded into claims reducer, search/resolve if necessary.
2) get the item claims for each 2) get the item claims for each
@ -165,7 +165,6 @@ 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);
@ -319,7 +318,7 @@ export const doFetchItemsInCollection = (
return doFetchItemsInCollections(newOptions, cb); return doFetchItemsInCollections(newOptions, cb);
}; };
export const doCollectionEdit = (collectionId: string, params: CollectionEditParams) => async( export const doCollectionEdit = (collectionId: string, params: CollectionEditParams) => async (
dispatch: Dispatch, dispatch: Dispatch,
getState: GetState getState: GetState
) => { ) => {

View file

@ -69,8 +69,7 @@ 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;
@ -113,17 +112,15 @@ 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 => {
if (!json.success) return uploadError(json.message || downMessage); return json.success
if (cb) { ? dispatch({
cb(json.data.serveUrl); type: ACTIONS.UPDATE_PUBLISH_FORM,
} data: {
return dispatch({ uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
type: ACTIONS.UPDATE_PUBLISH_FORM, thumbnail: json.data.serveUrl,
data: { },
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE, })
thumbnail: json.data.serveUrl, : uploadError(json.message || downMessage);
},
});
}) })
.catch(err => { .catch(err => {
let message = err.message; let message = err.message;

View file

@ -14,7 +14,6 @@ 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>,
}, },
@ -32,7 +31,6 @@ 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;
@ -47,7 +45,6 @@ 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 } : {}),
}; };
@ -68,7 +65,6 @@ 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);
@ -84,7 +80,6 @@ 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,
}, },

View file

@ -90,15 +90,8 @@ const collectionsReducer = handleActions(
[ACTIONS.COLLECTION_PENDING]: (state, action) => { [ACTIONS.COLLECTION_PENDING]: (state, action) => {
const { localId, claimId } = action.data; const { localId, claimId } = action.data;
const { const { edited: editList, unpublished: unpublishedList, pending: pendingList } = state;
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);
@ -108,10 +101,7 @@ const collectionsReducer = handleActions(
delete newUnpublishedList[localId]; delete newUnpublishedList[localId];
} else { } else {
// edit update // edit update
newPendingList[claimId] = Object.assign( newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
{},
newEditList[claimId] || newResolvedList[claimId]
);
delete newEditList[claimId]; delete newEditList[claimId];
} }
@ -168,15 +158,9 @@ const collectionsReducer = handleActions(
}); });
}, },
[ACTIONS.USER_STATE_POPULATE]: (state, action) => { [ACTIONS.USER_STATE_POPULATE]: (state, action) => {
const { const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
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,

View file

@ -165,7 +165,7 @@ export const makeSelectClaimForUri = (uri: string, returnRepost: boolean = true)
return { return {
...repostedClaim, ...repostedClaim,
repost_url: normalizeURI(uri), repost_url: 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,
}; };
@ -299,8 +299,8 @@ export const makeSelectMyPurchasesForPage = (query: ?string, page: number = 1) =
const end = Number(page) * Number(CLAIM.PAGE_SIZE); const end = Number(page) * Number(CLAIM.PAGE_SIZE);
return matchingFileInfos && matchingFileInfos.length return matchingFileInfos && matchingFileInfos.length
? matchingFileInfos ? matchingFileInfos
.slice(start, end) .slice(start, end)
.map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url) .map(fileInfo => fileInfo.canonical_url || fileInfo.permanent_url)
: []; : [];
} }
); );
@ -393,8 +393,8 @@ export const makeSelectDateForUri = (uri: string) =>
(claim.value.release_time (claim.value.release_time
? claim.value.release_time * 1000 ? claim.value.release_time * 1000
: claim.meta && claim.meta.creation_timestamp : claim.meta && claim.meta.creation_timestamp
? claim.meta.creation_timestamp * 1000 ? claim.meta.creation_timestamp * 1000
: null); : null);
if (!timestamp) { if (!timestamp) {
return undefined; return undefined;
} }
@ -630,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[normalizeURI(uri)] byUri => byUri && byUri[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[normalizeURI(uri)] / pageSize) byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)
); );
export const makeSelectNsfwCountFromUris = (uris: Array<string>) => export const makeSelectNsfwCountFromUris = (uris: Array<string>) =>

View file

@ -1,5 +1,4 @@
// @flow // @flow
import fromEntries from '@ungap/from-entries';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { import {
selectMyCollectionIds, selectMyCollectionIds,
@ -80,7 +79,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 = fromEntries( const myPublishedCollections = Object.fromEntries(
Object.entries(pending).concat( Object.entries(pending).concat(
Object.entries(resolved).filter( Object.entries(resolved).filter(
([key, val]) => ([key, val]) =>
@ -101,7 +100,7 @@ export const selectMyPublishedCollections = createSelector(
export const selectMyPublishedMixedCollections = createSelector( export const selectMyPublishedMixedCollections = createSelector(
selectMyPublishedCollections, selectMyPublishedCollections,
published => { published => {
const myCollections = fromEntries( const myCollections = Object.fromEntries(
// $FlowFixMe // $FlowFixMe
Object.entries(published).filter(([key, collection]) => { Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe // $FlowFixMe
@ -115,7 +114,7 @@ export const selectMyPublishedMixedCollections = createSelector(
export const selectMyPublishedPlaylistCollections = createSelector( export const selectMyPublishedPlaylistCollections = createSelector(
selectMyPublishedCollections, selectMyPublishedCollections,
published => { published => {
const myCollections = fromEntries( const myCollections = Object.fromEntries(
// $FlowFixMe // $FlowFixMe
Object.entries(published).filter(([key, collection]) => { Object.entries(published).filter(([key, collection]) => {
// $FlowFixMe // $FlowFixMe
@ -136,7 +135,7 @@ export const makeSelectMyPublishedCollectionForId = (id: string) =>
// selectResolvedCollections, // selectResolvedCollections,
// selectSavedCollectionIds, // selectSavedCollectionIds,
// (resolved, myIds) => { // (resolved, myIds) => {
// const mySavedCollections = fromEntries( // const mySavedCollections = Object.fromEntries(
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key)) // Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
// ); // );
// return mySavedCollections; // return mySavedCollections;
@ -164,28 +163,6 @@ export const makeSelectCollectionForId = (id: string) =>
} }
); );
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),
@ -213,18 +190,14 @@ 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),
(shuffleState, urls, claim) => { (urls, claim) => {
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls; const index = urls && urls.findIndex(u => u === url);
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 = listUrls && listUrls.findIndex(u => u === claim.permanent_url); const index = urls && urls.findIndex(u => u === claim.permanent_url);
if (index > -1) return index; if (index > -1) return index;
return claim; return claim;
} }
@ -232,49 +205,20 @@ 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),
(shuffleState, loopState, index, urls) => { (index, claims, 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
let remainingUrls = listUrls.slice(index + 1); const remainingUrls = urls.slice(index + 1);
if (!remainingUrls.length && loopList) { const nextUrl = remainingUrls.find(
remainingUrls = listUrls.slice(0); u =>
} claims[u].value.stream_type &&
const nextUrl = remainingUrls && remainingUrls[0]; (claims[u].value.stream_type === 'video' || claims[u].value.stream_type === 'audio')
);
return nextUrl || null; return nextUrl || null;
} else { } else {
return null; return null;
@ -298,13 +242,7 @@ export const makeSelectCountForCollectionId = (id: string) =>
if (collection.itemCount !== undefined) { if (collection.itemCount !== undefined) {
return collection.itemCount; return collection.itemCount;
} }
let itemCount = 0; return collection.items.length;
collection.items.map(item => {
if (item) {
itemCount += 1;
}
});
return itemCount;
} }
return null; return null;
} }

View file

@ -1411,11 +1411,6 @@
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"