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 |
16 changed files with 382 additions and 106 deletions
191
dist/bundle.es.js
vendored
191
dist/bundle.es.js
vendored
|
@ -2,9 +2,12 @@
|
|||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
require('proxy-polyfill');
|
||||
var uuid = require('uuid');
|
||||
var reselect = require('reselect');
|
||||
var fromEntries = _interopDefault(require('@ungap/from-entries'));
|
||||
|
||||
const MINIMUM_PUBLISH_BID = 0.00000001;
|
||||
|
||||
|
@ -716,7 +719,7 @@ const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
|
|||
const THEME = 'theme';
|
||||
const THEMES = 'themes';
|
||||
const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
||||
const AUTOPLAY = 'autoplay';
|
||||
const AUTOPLAY_MEDIA = 'autoplay';
|
||||
const AUTOPLAY_NEXT = 'autoplay_next';
|
||||
const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
||||
const AUTO_DOWNLOAD = 'auto_download';
|
||||
|
@ -732,6 +735,8 @@ const ENABLE_PUBLISH_PREVIEW = 'enable-publish-preview';
|
|||
const TILE_LAYOUT = 'tile_layout';
|
||||
const VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||
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
|
||||
const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
||||
|
@ -765,7 +770,7 @@ var settings = /*#__PURE__*/Object.freeze({
|
|||
THEME: THEME,
|
||||
THEMES: THEMES,
|
||||
AUTOMATIC_DARK_MODE_ENABLED: AUTOMATIC_DARK_MODE_ENABLED,
|
||||
AUTOPLAY: AUTOPLAY,
|
||||
AUTOPLAY_MEDIA: AUTOPLAY_MEDIA,
|
||||
AUTOPLAY_NEXT: AUTOPLAY_NEXT,
|
||||
OS_NOTIFICATIONS_ENABLED: OS_NOTIFICATIONS_ENABLED,
|
||||
AUTO_DOWNLOAD: AUTO_DOWNLOAD,
|
||||
|
@ -781,6 +786,8 @@ var settings = /*#__PURE__*/Object.freeze({
|
|||
TILE_LAYOUT: TILE_LAYOUT,
|
||||
VIDEO_THEATER_MODE: VIDEO_THEATER_MODE,
|
||||
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,
|
||||
FOREGROUND_NOTIFICATION_ENABLED: FOREGROUND_NOTIFICATION_ENABLED,
|
||||
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];
|
||||
|
||||
// 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({
|
||||
SDK_SYNC_KEYS: SDK_SYNC_KEYS,
|
||||
|
@ -1473,7 +1480,7 @@ const channelNameMinLength = 1;
|
|||
const claimIdMaxLength = 40;
|
||||
|
||||
// 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 regexPartProtocol = '^((?:lbry://)?)';
|
||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||
|
@ -1481,6 +1488,11 @@ const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
|||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||
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
|
||||
* messages for invalid names.
|
||||
|
@ -1582,11 +1594,11 @@ function parseURIModifier(modSeperator, modValue) {
|
|||
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;
|
||||
} else if (modSeperator === ':') {
|
||||
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) {
|
||||
claimSequence = modValue;
|
||||
} else if (modSeperator === '$') {
|
||||
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) {
|
||||
bidPosition = modValue;
|
||||
}
|
||||
}
|
||||
|
@ -1717,6 +1729,25 @@ function convertToShareLink(URL) {
|
|||
}, 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 */
|
||||
// underscore's deep equal function
|
||||
// https://github.com/jashkenas/underscore/blob/master/underscore.js#L1189
|
||||
|
@ -1840,11 +1871,12 @@ function extractUserState(rawObj) {
|
|||
app_welcome_version,
|
||||
sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections
|
||||
} = 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 {};
|
||||
|
@ -1862,6 +1894,7 @@ function doPopulateSharedUserState(sharedSettings) {
|
|||
app_welcome_version,
|
||||
sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections
|
||||
} = extractUserState(sharedSettings);
|
||||
|
@ -1877,6 +1910,7 @@ function doPopulateSharedUserState(sharedSettings) {
|
|||
welcomeVersion: app_welcome_version,
|
||||
allowAnalytics: sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections
|
||||
}
|
||||
|
@ -2412,7 +2446,7 @@ const selectClaimsByUri = reselect.createSelector(selectClaimIdsByUri, selectCla
|
|||
|
||||
const selectAllClaimsByChannel = reselect.createSelector(selectState$1, state => state.paginatedClaimsByChannel || {});
|
||||
|
||||
const selectPendingIds = reselect.createSelector(selectState$1, state => Object.keys(state.pendingIds) || []);
|
||||
const selectPendingIds = reselect.createSelector(selectState$1, state => Object.keys(state.pendingById) || []);
|
||||
|
||||
const selectPendingClaims = reselect.createSelector(selectPendingClaimsById, pendingById => Object.values(pendingById));
|
||||
|
||||
|
@ -2461,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);
|
||||
|
||||
return _extends$3({}, repostedClaim, {
|
||||
repost_url: uri,
|
||||
repost_url: normalizeURI(uri),
|
||||
repost_channel_url: channelUrl,
|
||||
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount
|
||||
});
|
||||
|
@ -2712,9 +2746,9 @@ const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendin
|
|||
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 claim = claims[uri];
|
||||
|
@ -3617,7 +3651,7 @@ const makeSelectCollectionIsMine = id => reselect.createSelector(selectMyCollect
|
|||
|
||||
const selectMyPublishedCollections = reselect.createSelector(selectResolvedCollections, selectPendingCollections, selectMyEditedCollections, selectMyCollectionIds, (resolved, pending, edited, myIds) => {
|
||||
// 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
|
||||
!pending[key])));
|
||||
// now add in edited:
|
||||
|
@ -3628,7 +3662,7 @@ const selectMyPublishedCollections = reselect.createSelector(selectResolvedColle
|
|||
});
|
||||
|
||||
const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
||||
const myCollections = Object.fromEntries(
|
||||
const myCollections = fromEntries(
|
||||
// $FlowFixMe
|
||||
Object.entries(published).filter(([key, collection]) => {
|
||||
// $FlowFixMe
|
||||
|
@ -3638,7 +3672,7 @@ const selectMyPublishedMixedCollections = reselect.createSelector(selectMyPublis
|
|||
});
|
||||
|
||||
const selectMyPublishedPlaylistCollections = reselect.createSelector(selectMyPublishedCollections, published => {
|
||||
const myCollections = Object.fromEntries(
|
||||
const myCollections = fromEntries(
|
||||
// $FlowFixMe
|
||||
Object.entries(published).filter(([key, collection]) => {
|
||||
// $FlowFixMe
|
||||
|
@ -3653,7 +3687,7 @@ const makeSelectMyPublishedCollectionForId = id => reselect.createSelector(selec
|
|||
// selectResolvedCollections,
|
||||
// selectSavedCollectionIds,
|
||||
// (resolved, myIds) => {
|
||||
// const mySavedCollections = Object.fromEntries(
|
||||
// const mySavedCollections = fromEntries(
|
||||
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
||||
// );
|
||||
// return mySavedCollections;
|
||||
|
@ -3669,6 +3703,20 @@ const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCol
|
|||
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 makeSelectUrlsForCollectionId = id => reselect.createSelector(makeSelectCollectionForId(id), collection => collection && collection.items);
|
||||
|
@ -3682,23 +3730,51 @@ const makeSelectClaimIdsForCollectionId = id => reselect.createSelector(makeSele
|
|||
return ids;
|
||||
});
|
||||
|
||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (urls, claim) => {
|
||||
const index = urls && urls.findIndex(u => u === url);
|
||||
const makeSelectIndexForUrlInCollection = (url, id) => reselect.createSelector(state => state.content.shuffleList, makeSelectUrlsForCollectionId(id), makeSelectClaimForUri(url), (shuffleState, urls, claim) => {
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const listUrls = shuffleUrls || urls;
|
||||
|
||||
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} 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;
|
||||
return claim;
|
||||
}
|
||||
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) {
|
||||
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
|
||||
const remainingUrls = urls.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'));
|
||||
let remainingUrls = listUrls.slice(index + 1);
|
||||
if (!remainingUrls.length && loopList) {
|
||||
remainingUrls = listUrls.slice(0);
|
||||
}
|
||||
const nextUrl = remainingUrls && remainingUrls[0];
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -3714,7 +3790,13 @@ const makeSelectCountForCollectionId = id => reselect.createSelector(makeSelectC
|
|||
if (collection.itemCount !== undefined) {
|
||||
return collection.itemCount;
|
||||
}
|
||||
return collection.items.length;
|
||||
let itemCount = 0;
|
||||
collection.items.map(item => {
|
||||
if (item) {
|
||||
itemCount += 1;
|
||||
}
|
||||
});
|
||||
return itemCount;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
@ -4420,11 +4502,15 @@ function doCollectionPublish(options, localId) {
|
|||
};
|
||||
}
|
||||
|
||||
function doCollectionPublishUpdate(options) {
|
||||
return dispatch => {
|
||||
function doCollectionPublishUpdate(options, isBackgroundUpdate) {
|
||||
return (dispatch, getState) => {
|
||||
// TODO: implement one click update
|
||||
|
||||
const updateParams = {
|
||||
const updateParams = isBackgroundUpdate ? {
|
||||
blocking: true,
|
||||
claim_id: options.claim_id,
|
||||
clear_claims: true
|
||||
} : {
|
||||
bid: creditsToString(options.bid),
|
||||
title: options.title,
|
||||
thumbnail_url: options.thumbnail_url,
|
||||
|
@ -4434,16 +4520,25 @@ function doCollectionPublishUpdate(options) {
|
|||
locations: [],
|
||||
blocking: true,
|
||||
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) {
|
||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||
}
|
||||
|
||||
if (options.claims) {
|
||||
updateParams['claims'] = options.claims;
|
||||
if (options.channel_id) {
|
||||
updateParams['channel_id'] = options.channel_id;
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
dispatch({
|
||||
type: COLLECTION_PUBLISH_UPDATE_STARTED
|
||||
|
@ -4613,7 +4708,7 @@ const getTimestamp = () => {
|
|||
return Math.floor(Date.now() / 1000);
|
||||
};
|
||||
|
||||
const FETCH_BATCH_SIZE = 10;
|
||||
const FETCH_BATCH_SIZE = 50;
|
||||
|
||||
const doLocalCollectionCreate = (name, collectionItems, type, sourceId) => dispatch => {
|
||||
return dispatch({
|
||||
|
@ -4720,7 +4815,8 @@ const doFetchItemsInCollections = (resolveItemsOptions, resolveStartedCallback)
|
|||
batches[i] = lbryProxy.claim_search({
|
||||
claim_ids: claim.value.claims,
|
||||
page: i + 1,
|
||||
page_size: batchSize
|
||||
page_size: batchSize,
|
||||
no_totals: true
|
||||
});
|
||||
}
|
||||
const itemsInBatches = yield Promise.all(batches);
|
||||
|
@ -5537,7 +5633,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
|
|||
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.');
|
||||
let thumbnail, fileExt, fileName, fileType;
|
||||
|
||||
|
@ -5571,13 +5667,17 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
|
|||
method: 'POST',
|
||||
body: data
|
||||
}).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,
|
||||
data: {
|
||||
uploadThumbnailStatus: COMPLETE,
|
||||
thumbnail: json.data.serveUrl
|
||||
}
|
||||
}) : uploadError(json.message || downMessage);
|
||||
});
|
||||
}).catch(err => {
|
||||
let message = err.message;
|
||||
|
||||
|
@ -7672,8 +7772,15 @@ const collectionsReducer = handleActions({
|
|||
|
||||
[COLLECTION_PENDING]: (state, action) => {
|
||||
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 newResolvedList = Object.assign({}, resolvedList);
|
||||
const newUnpublishedList = Object.assign({}, unpublishedList);
|
||||
const newPendingList = Object.assign({}, pendingList);
|
||||
|
||||
|
@ -7683,7 +7790,7 @@ const collectionsReducer = handleActions({
|
|||
delete newUnpublishedList[localId];
|
||||
} else {
|
||||
// edit update
|
||||
newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
|
||||
newPendingList[claimId] = Object.assign({}, newEditList[claimId] || newResolvedList[claimId]);
|
||||
delete newEditList[claimId];
|
||||
}
|
||||
|
||||
|
@ -7735,8 +7842,14 @@ const collectionsReducer = handleActions({
|
|||
}));
|
||||
},
|
||||
[USER_STATE_POPULATE]: (state, action) => {
|
||||
const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
|
||||
const {
|
||||
builtinCollections,
|
||||
savedCollections,
|
||||
unpublishedCollections,
|
||||
editedCollections
|
||||
} = action.data;
|
||||
return _extends$e({}, state, {
|
||||
edited: editedCollections || state.edited,
|
||||
unpublished: unpublishedCollections || state.unpublished,
|
||||
builtin: builtinCollections || state.builtin,
|
||||
saved: savedCollections || state.saved
|
||||
|
@ -7936,6 +8049,7 @@ exports.formatFullPrice = formatFullPrice;
|
|||
exports.isClaimNsfw = isClaimNsfw;
|
||||
exports.isNameValid = isNameValid;
|
||||
exports.isURIClaimable = isURIClaimable;
|
||||
exports.isURIEqual = isURIEqual;
|
||||
exports.isURIValid = isURIValid;
|
||||
exports.makeSelectAbandoningClaimById = makeSelectAbandoningClaimById;
|
||||
exports.makeSelectAmountForUri = makeSelectAmountForUri;
|
||||
|
@ -7952,6 +8066,7 @@ exports.makeSelectClaimIsMine = makeSelectClaimIsMine;
|
|||
exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw;
|
||||
exports.makeSelectClaimIsPending = makeSelectClaimIsPending;
|
||||
exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder;
|
||||
exports.makeSelectClaimUrlInCollection = makeSelectClaimUrlInCollection;
|
||||
exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased;
|
||||
exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage;
|
||||
exports.makeSelectCollectionForId = makeSelectCollectionForId;
|
||||
|
@ -7992,6 +8107,7 @@ exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri;
|
|||
exports.makeSelectPendingClaimForUri = makeSelectPendingClaimForUri;
|
||||
exports.makeSelectPendingCollectionForId = makeSelectPendingCollectionForId;
|
||||
exports.makeSelectPermanentUrlForUri = makeSelectPermanentUrlForUri;
|
||||
exports.makeSelectPreviousUrlForCollectionAndUrl = makeSelectPreviousUrlForCollectionAndUrl;
|
||||
exports.makeSelectPublishFormValue = makeSelectPublishFormValue;
|
||||
exports.makeSelectPublishedCollectionForId = makeSelectPublishedCollectionForId;
|
||||
exports.makeSelectReflectingClaimForUri = makeSelectReflectingClaimForUri;
|
||||
|
@ -8151,5 +8267,6 @@ exports.selectWalletState = selectWalletState;
|
|||
exports.selectWalletUnlockPending = selectWalletUnlockPending;
|
||||
exports.selectWalletUnlockResult = selectWalletUnlockResult;
|
||||
exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded;
|
||||
exports.splitBySeparator = splitBySeparator;
|
||||
exports.toQueryString = toQueryString;
|
||||
exports.walletReducer = walletReducer;
|
||||
|
|
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;
|
||||
}
|
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"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ungap/from-entries": "^0.2.1",
|
||||
"proxy-polyfill": "0.1.6",
|
||||
"reselect": "^3.0.0",
|
||||
"uuid": "^8.3.1"
|
||||
|
|
|
@ -23,7 +23,7 @@ export const INSTANT_PURCHASE_MAX = 'instant_purchase_max';
|
|||
export const THEME = 'theme';
|
||||
export const THEMES = 'themes';
|
||||
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 OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
||||
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 VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||
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
|
||||
export const BACKGROUND_PLAY_ENABLED = 'backgroundPlayEnabled';
|
||||
|
|
|
@ -21,10 +21,12 @@ export const CLIENT_SYNC_KEYS = [
|
|||
SETTINGS.INSTANT_PURCHASE_ENABLED,
|
||||
SETTINGS.INSTANT_PURCHASE_MAX,
|
||||
SETTINGS.THEME,
|
||||
SETTINGS.AUTOPLAY,
|
||||
SETTINGS.AUTOPLAY_MEDIA,
|
||||
SETTINGS.AUTOPLAY_NEXT,
|
||||
SETTINGS.HIDE_BALANCE,
|
||||
SETTINGS.HIDE_SPLASH_ANIMATION,
|
||||
SETTINGS.FLOATING_PLAYER,
|
||||
SETTINGS.DARK_MODE_TIMES,
|
||||
SETTINGS.AUTOMATIC_DARK_MODE_ENABLED,
|
||||
SETTINGS.LANGUAGE,
|
||||
];
|
||||
|
|
|
@ -52,6 +52,8 @@ export {
|
|||
isURIClaimable,
|
||||
isNameValid,
|
||||
convertToShareLink,
|
||||
splitBySeparator,
|
||||
isURIEqual,
|
||||
} from 'lbryURI';
|
||||
|
||||
// middlware
|
||||
|
@ -174,12 +176,14 @@ export {
|
|||
makeSelectMyPublishedCollectionForId,
|
||||
makeSelectUnpublishedCollectionForId,
|
||||
makeSelectCollectionForId,
|
||||
makeSelectClaimUrlInCollection,
|
||||
makeSelectUrlsForCollectionId,
|
||||
makeSelectClaimIdsForCollectionId,
|
||||
makeSelectNameForCollectionId,
|
||||
makeSelectCountForCollectionId,
|
||||
makeSelectIsResolvingCollectionForId,
|
||||
makeSelectIndexForUrlInCollection,
|
||||
makeSelectPreviousUrlForCollectionAndUrl,
|
||||
makeSelectNextUrlForCollectionAndUrl,
|
||||
makeSelectCollectionForIdHasClaimUrl,
|
||||
} from 'redux/selectors/collections';
|
||||
|
|
|
@ -4,7 +4,7 @@ const channelNameMinLength = 1;
|
|||
const claimIdMaxLength = 40;
|
||||
|
||||
// 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}$/;
|
||||
const regexPartProtocol = '^((?:lbry://)?)';
|
||||
const regexPartStreamOrChannelName = '([^:$#/]*)';
|
||||
|
@ -12,6 +12,11 @@ const regexPartModifierSeparator = '([:$#]?)([^/]*)';
|
|||
const queryStringBreaker = '^([\\S]+)([?][\\S]*)';
|
||||
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
|
||||
* messages for invalid names.
|
||||
|
@ -144,11 +149,11 @@ function parseURIModifier(modSeperator: ?string, modValue: ?string) {
|
|||
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;
|
||||
} else if (modSeperator === ':') {
|
||||
} else if (modSeperator === MOD_SEQUENCE_SEPARATOR) {
|
||||
claimSequence = modValue;
|
||||
} else if (modSeperator === '$') {
|
||||
} else if (modSeperator === MOD_BID_POSITION_SEPARATOR) {
|
||||
bidPosition = modValue;
|
||||
}
|
||||
}
|
||||
|
@ -320,3 +325,22 @@ export function convertToShareLink(URL: string) {
|
|||
'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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ import { creditsToString } from 'util/format-credits';
|
|||
import { batchActions } from 'util/batch-actions';
|
||||
import { createNormalizedClaimSearchKey } from 'util/claim';
|
||||
import { PAGE_SIZE } from 'constants/claim';
|
||||
import { selectPendingCollections } from 'redux/selectors/collections';
|
||||
import {
|
||||
selectPendingCollections,
|
||||
makeSelectClaimIdsForCollectionId,
|
||||
} from 'redux/selectors/collections';
|
||||
import {
|
||||
doFetchItemsInCollection,
|
||||
doFetchItemsInCollections,
|
||||
|
@ -828,7 +831,8 @@ export function doCollectionPublish(
|
|||
};
|
||||
}
|
||||
|
||||
export function doCollectionPublishUpdate(options: {
|
||||
export function doCollectionPublishUpdate(
|
||||
options: {
|
||||
bid?: string,
|
||||
blocking?: true,
|
||||
title?: string,
|
||||
|
@ -838,8 +842,11 @@ export function doCollectionPublishUpdate(options: {
|
|||
tags?: Array<Tag>,
|
||||
languages?: Array<string>,
|
||||
claims?: Array<string>,
|
||||
}) {
|
||||
return (dispatch: Dispatch): Promise<any> => {
|
||||
channel_id?: string,
|
||||
},
|
||||
isBackgroundUpdate?: boolean
|
||||
) {
|
||||
return (dispatch: Dispatch, getState: GetState): Promise<any> => {
|
||||
// TODO: implement one click update
|
||||
|
||||
const updateParams: {
|
||||
|
@ -847,13 +854,21 @@ export function doCollectionPublishUpdate(options: {
|
|||
blocking?: true,
|
||||
title?: string,
|
||||
thumbnail_url?: string,
|
||||
channel_id?: string,
|
||||
description?: string,
|
||||
claim_id: string,
|
||||
tags?: Array<string>,
|
||||
languages?: Array<string>,
|
||||
claims?: Array<string>,
|
||||
clear_claims: boolean,
|
||||
} = {
|
||||
replace?: boolean,
|
||||
} = isBackgroundUpdate
|
||||
? {
|
||||
blocking: true,
|
||||
claim_id: options.claim_id,
|
||||
clear_claims: true,
|
||||
}
|
||||
: {
|
||||
bid: creditsToString(options.bid),
|
||||
title: options.title,
|
||||
thumbnail_url: options.thumbnail_url,
|
||||
|
@ -864,15 +879,24 @@ export function doCollectionPublishUpdate(options: {
|
|||
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) {
|
||||
updateParams['tags'] = options.tags.map(tag => tag.name);
|
||||
}
|
||||
|
||||
if (options.claims) {
|
||||
updateParams['claims'] = options.claims;
|
||||
if (options.channel_id) {
|
||||
updateParams['channel_id'] = options.channel_id;
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_PUBLISH_UPDATE_STARTED,
|
||||
|
|
|
@ -18,7 +18,7 @@ const getTimestamp = () => {
|
|||
return Math.floor(Date.now() / 1000);
|
||||
};
|
||||
|
||||
const FETCH_BATCH_SIZE = 10;
|
||||
const FETCH_BATCH_SIZE = 50;
|
||||
|
||||
export const doLocalCollectionCreate = (
|
||||
name: string,
|
||||
|
@ -165,6 +165,7 @@ export const doFetchItemsInCollections = (
|
|||
claim_ids: claim.value.claims,
|
||||
page: i + 1,
|
||||
page_size: batchSize,
|
||||
no_totals: true,
|
||||
});
|
||||
}
|
||||
const itemsInBatches = await Promise.all(batches);
|
||||
|
|
|
@ -69,7 +69,8 @@ export const doUploadThumbnail = (
|
|||
thumbnailBlob?: File,
|
||||
fsAdapter?: any,
|
||||
fs?: any,
|
||||
path?: any
|
||||
path?: any,
|
||||
cb?: (string) => void
|
||||
) => (dispatch: Dispatch) => {
|
||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||
let thumbnail, fileExt, fileName, fileType;
|
||||
|
@ -112,15 +113,17 @@ export const doUploadThumbnail = (
|
|||
.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: ACTIONS.UPDATE_PUBLISH_FORM,
|
||||
data: {
|
||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
||||
thumbnail: json.data.serveUrl,
|
||||
},
|
||||
})
|
||||
: uploadError(json.message || downMessage);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
let message = err.message;
|
||||
|
|
|
@ -14,6 +14,7 @@ type SharedData = {
|
|||
app_welcome_version?: number,
|
||||
sharing_3P?: boolean,
|
||||
unpublishedCollections: CollectionGroup,
|
||||
editedCollections: CollectionGroup,
|
||||
builtinCollections: CollectionGroup,
|
||||
savedCollections: Array<string>,
|
||||
},
|
||||
|
@ -31,6 +32,7 @@ function extractUserState(rawObj: SharedData) {
|
|||
app_welcome_version,
|
||||
sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections,
|
||||
} = rawObj.value;
|
||||
|
@ -45,6 +47,7 @@ function extractUserState(rawObj: SharedData) {
|
|||
...(app_welcome_version ? { app_welcome_version } : {}),
|
||||
...(sharing_3P ? { sharing_3P } : {}),
|
||||
...(unpublishedCollections ? { unpublishedCollections } : {}),
|
||||
...(editedCollections ? { editedCollections } : {}),
|
||||
...(builtinCollections ? { builtinCollections } : {}),
|
||||
...(savedCollections ? { savedCollections } : {}),
|
||||
};
|
||||
|
@ -65,6 +68,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
|||
app_welcome_version,
|
||||
sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections,
|
||||
} = extractUserState(sharedSettings);
|
||||
|
@ -80,6 +84,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
|
|||
welcomeVersion: app_welcome_version,
|
||||
allowAnalytics: sharing_3P,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
builtinCollections,
|
||||
savedCollections,
|
||||
},
|
||||
|
|
|
@ -90,8 +90,15 @@ const collectionsReducer = handleActions(
|
|||
|
||||
[ACTIONS.COLLECTION_PENDING]: (state, action) => {
|
||||
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 newResolvedList = Object.assign({}, resolvedList);
|
||||
const newUnpublishedList = Object.assign({}, unpublishedList);
|
||||
const newPendingList = Object.assign({}, pendingList);
|
||||
|
||||
|
@ -101,7 +108,10 @@ const collectionsReducer = handleActions(
|
|||
delete newUnpublishedList[localId];
|
||||
} else {
|
||||
// edit update
|
||||
newPendingList[claimId] = Object.assign({}, newEditList[claimId]);
|
||||
newPendingList[claimId] = Object.assign(
|
||||
{},
|
||||
newEditList[claimId] || newResolvedList[claimId]
|
||||
);
|
||||
delete newEditList[claimId];
|
||||
}
|
||||
|
||||
|
@ -158,9 +168,15 @@ const collectionsReducer = handleActions(
|
|||
});
|
||||
},
|
||||
[ACTIONS.USER_STATE_POPULATE]: (state, action) => {
|
||||
const { builtinCollections, savedCollections, unpublishedCollections } = action.data;
|
||||
const {
|
||||
builtinCollections,
|
||||
savedCollections,
|
||||
unpublishedCollections,
|
||||
editedCollections,
|
||||
} = action.data;
|
||||
return {
|
||||
...state,
|
||||
edited: editedCollections || state.edited,
|
||||
unpublished: unpublishedCollections || state.unpublished,
|
||||
builtin: builtinCollections || state.builtin,
|
||||
saved: savedCollections || state.saved,
|
||||
|
|
|
@ -85,7 +85,7 @@ export const selectAllClaimsByChannel = createSelector(
|
|||
|
||||
export const selectPendingIds = createSelector(
|
||||
selectState,
|
||||
state => Object.keys(state.pendingIds) || []
|
||||
state => Object.keys(state.pendingById) || []
|
||||
);
|
||||
|
||||
export const selectPendingClaims = createSelector(
|
||||
|
@ -165,7 +165,7 @@ export const makeSelectClaimForUri = (uri: string, returnRepost: boolean = true)
|
|||
|
||||
return {
|
||||
...repostedClaim,
|
||||
repost_url: uri,
|
||||
repost_url: normalizeURI(uri),
|
||||
repost_channel_url: channelUrl,
|
||||
repost_bid_amount: claim && claim.meta && claim.meta.effective_amount,
|
||||
};
|
||||
|
@ -630,13 +630,13 @@ export const makeSelectPendingClaimForUri = (uri: string) =>
|
|||
export const makeSelectTotalItemsForChannel = (uri: string) =>
|
||||
createSelector(
|
||||
selectChannelClaimCounts,
|
||||
byUri => byUri && byUri[uri]
|
||||
byUri => byUri && byUri[normalizeURI(uri)]
|
||||
);
|
||||
|
||||
export const makeSelectTotalPagesForChannel = (uri: string, pageSize: number = 10) =>
|
||||
createSelector(
|
||||
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>) =>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
import fromEntries from '@ungap/from-entries';
|
||||
import { createSelector } from 'reselect';
|
||||
import {
|
||||
selectMyCollectionIds,
|
||||
|
@ -79,7 +80,7 @@ export const selectMyPublishedCollections = createSelector(
|
|||
selectMyCollectionIds,
|
||||
(resolved, pending, edited, myIds) => {
|
||||
// all resolved in myIds, plus those in pending and edited
|
||||
const myPublishedCollections = Object.fromEntries(
|
||||
const myPublishedCollections = fromEntries(
|
||||
Object.entries(pending).concat(
|
||||
Object.entries(resolved).filter(
|
||||
([key, val]) =>
|
||||
|
@ -100,7 +101,7 @@ export const selectMyPublishedCollections = createSelector(
|
|||
export const selectMyPublishedMixedCollections = createSelector(
|
||||
selectMyPublishedCollections,
|
||||
published => {
|
||||
const myCollections = Object.fromEntries(
|
||||
const myCollections = fromEntries(
|
||||
// $FlowFixMe
|
||||
Object.entries(published).filter(([key, collection]) => {
|
||||
// $FlowFixMe
|
||||
|
@ -114,7 +115,7 @@ export const selectMyPublishedMixedCollections = createSelector(
|
|||
export const selectMyPublishedPlaylistCollections = createSelector(
|
||||
selectMyPublishedCollections,
|
||||
published => {
|
||||
const myCollections = Object.fromEntries(
|
||||
const myCollections = fromEntries(
|
||||
// $FlowFixMe
|
||||
Object.entries(published).filter(([key, collection]) => {
|
||||
// $FlowFixMe
|
||||
|
@ -135,7 +136,7 @@ export const makeSelectMyPublishedCollectionForId = (id: string) =>
|
|||
// selectResolvedCollections,
|
||||
// selectSavedCollectionIds,
|
||||
// (resolved, myIds) => {
|
||||
// const mySavedCollections = Object.fromEntries(
|
||||
// const mySavedCollections = fromEntries(
|
||||
// Object.entries(resolved).filter(([key, val]) => myIds.includes(key))
|
||||
// );
|
||||
// return mySavedCollections;
|
||||
|
@ -163,6 +164,28 @@ 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) =>
|
||||
createSelector(
|
||||
makeSelectCollectionForId(id),
|
||||
|
@ -190,14 +213,18 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
|||
|
||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||
createSelector(
|
||||
state => state.content.shuffleList,
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
makeSelectClaimForUri(url),
|
||||
(urls, claim) => {
|
||||
const index = urls && urls.findIndex(u => u === url);
|
||||
(shuffleState, urls, claim) => {
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const listUrls = shuffleUrls || urls;
|
||||
|
||||
const index = listUrls && listUrls.findIndex(u => u === url);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
} 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;
|
||||
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) =>
|
||||
createSelector(
|
||||
state => state.content.shuffleList,
|
||||
state => state.content.loopList,
|
||||
makeSelectIndexForUrlInCollection(url, id),
|
||||
selectClaimsByUri,
|
||||
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) {
|
||||
const listUrls = shuffleUrls || urls;
|
||||
// We'll get the next playble url
|
||||
const remainingUrls = urls.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')
|
||||
);
|
||||
let remainingUrls = listUrls.slice(index + 1);
|
||||
if (!remainingUrls.length && loopList) {
|
||||
remainingUrls = listUrls.slice(0);
|
||||
}
|
||||
const nextUrl = remainingUrls && remainingUrls[0];
|
||||
return nextUrl || null;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -242,7 +298,13 @@ export const makeSelectCountForCollectionId = (id: string) =>
|
|||
if (collection.itemCount !== undefined) {
|
||||
return collection.itemCount;
|
||||
}
|
||||
return collection.items.length;
|
||||
let itemCount = 0;
|
||||
collection.items.map(item => {
|
||||
if (item) {
|
||||
itemCount += 1;
|
||||
}
|
||||
});
|
||||
return itemCount;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1411,6 +1411,11 @@
|
|||
dependencies:
|
||||
"@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:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
||||
|
|
Loading…
Reference in a new issue