diff --git a/dist/bundle.es.js b/dist/bundle.es.js index ee25f3d..924a275 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -898,7 +898,7 @@ const getSearchQueryString = (query, options = {}, includeUserOptions = false) = var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } -const channelNameMinLength = 1; +const channelNameMinLength = 2; const claimIdMaxLength = 40; // see https://spec.lbry.com/#urls @@ -960,7 +960,7 @@ function parseURI(URL, requireProto = false) { const includesChannel = streamNameOrChannelName.startsWith('@'); const isChannel = streamNameOrChannelName.startsWith('@') && !possibleStreamName; - const channelName = includesChannel && streamNameOrChannelName.slice(1); + const channelName = includesChannel && streamNameOrChannelName; if (includesChannel) { if (!channelName) { @@ -1725,7 +1725,7 @@ const makeSelectRecommendedContentForUri = uri => reselect.createSelector(makeSe let recommendedContent; if (claim) { // If we are at a vanity uri, build the full uri so we can properly filter - const currentUri = atVanityURI ? buildURI({ claimId: claim.claim_id, claimName: claim.name }) : uri; + const currentUri = atVanityURI ? buildURI({ streamClaimId: claim.claim_id, streamName: claim.name }) : uri; const { title } = claim.value; @@ -2594,99 +2594,6 @@ const selectTotalDownloadProgress = reselect.createSelector(selectDownloadingFil return -1; }); -const selectSearchDownloadUris = query => reselect.createSelector(selectFileInfosDownloaded, selectClaimsById, (fileInfos, claimsById) => { - if (!query || !fileInfos.length) { - return null; - } - - const queryParts = query.toLowerCase().split(' '); - const searchQueryDictionary = {}; - queryParts.forEach(subQuery => { - searchQueryDictionary[subQuery] = subQuery; - }); - - const arrayContainsQueryPart = array => { - for (let i = 0; i < array.length; i += 1) { - const subQuery = array[i]; - if (searchQueryDictionary[subQuery]) { - return true; - } - } - return false; - }; - - const downloadResultsFromQuery = []; - fileInfos.forEach(fileInfo => { - const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo; - const { author, description, title } = metadata; - - if (channelName) { - const lowerCaseChannel = channelName.toLowerCase(); - const strippedOutChannelName = lowerCaseChannel.slice(1); // trim off the @ - if (searchQueryDictionary[channelName] || searchQueryDictionary[strippedOutChannelName]) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - const nameParts = claimName.toLowerCase().split('-'); - if (arrayContainsQueryPart(nameParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - - if (title) { - const titleParts = title.toLowerCase().split(' '); - if (arrayContainsQueryPart(titleParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - if (author) { - const authorParts = author.toLowerCase().split(' '); - if (arrayContainsQueryPart(authorParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - if (description) { - const descriptionParts = description.toLowerCase().split(' '); - if (arrayContainsQueryPart(descriptionParts)) { - downloadResultsFromQuery.push(fileInfo); - } - } - }); - - return downloadResultsFromQuery.length ? downloadResultsFromQuery.map(fileInfo => { - const { - channel_name: channelName, - claim_id: claimId, - claim_name: claimName - } = fileInfo; - - const uriParams = {}; - - if (channelName) { - const claim = claimsById[claimId]; - if (claim && claim.signing_channel) { - uriParams.claimId = claim.signing_channel.claim_id; - } else { - uriParams.claimId = claimId; - } - uriParams.channelName = channelName; - uriParams.contentName = claimName; - } else { - uriParams.claimId = claimId; - uriParams.claimName = claimName; - } - - const uri = buildURI(uriParams); - return uri; - }) : null; -}); - const selectFileListPublishedSort = reselect.createSelector(selectState$3, state => state.fileListPublishedSort); const selectFileListDownloadedSort = reselect.createSelector(selectState$3, state => state.fileListDownloadedSort); @@ -2934,13 +2841,13 @@ const selectIsStillEditing = reselect.createSelector(selectPublishFormValues, pu const { isChannel: currentIsChannel, - channelName: currentClaimName, - streamName: currentContentName + streamName: currentClaimName, + channelName: currentContentName } = parseURI(uri); const { isChannel: editIsChannel, - channelName: editClaimName, - streamName: editContentName + streamName: editClaimName, + channelName: editContentName } = parseURI(editingURI); // Depending on the previous/current use of a channel, we need to compare different things @@ -2951,8 +2858,8 @@ const selectIsStillEditing = reselect.createSelector(selectPublishFormValues, pu }); const selectMyClaimForUri = reselect.createSelector(selectPublishFormValues, selectIsStillEditing, selectClaimsById, selectMyClaimsWithoutChannels, ({ editingURI, uri }, isStillEditing, claimsById, myClaims) => { - const { contentName, claimName } = parseURI(uri); - const { claimId: editClaimId } = parseURI(editingURI); + const { channelName: contentName, streamName: claimName } = parseURI(uri); + const { streamClaimId: editClaimId } = parseURI(editingURI); // If isStillEditing // They clicked "edit" from the file page @@ -2988,14 +2895,14 @@ const selectTakeOverAmount = reselect.createSelector(selectState$5, selectMyClai const claimForShortUri = claimsByUri[shortUri]; if (!myClaimForUri && claimForShortUri) { - return claimForShortUri.effective_amount; + return claimForShortUri.meta.effective_amount; } else if (myClaimForUri && claimForShortUri) { // https://github.com/lbryio/lbry/issues/1476 // We should check the current effective_amount on my claim to see how much additional lbc // is needed to win the claim. Currently this is not possible during a takeover. // With this, we could say something like, "You have x lbc in support, if you bid y additional LBC you will control the claim" // For now just ignore supports. We will just show the winning claim's bid amount - return claimForShortUri.effective_amount || claimForShortUri.amount; + return claimForShortUri.meta.effective_amount || claimForShortUri.amount; } return null; @@ -3680,7 +3587,7 @@ reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => { const pendingById = Object.assign({}, state.pendingById); claims.forEach(claim => { - const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id }); + const uri = buildURI({ streamName: claim.name, streamClaimId: claim.claim_id }); if (claim.type && claim.type.match(/claim|update/)) { if (claim.confirmations < 1) { @@ -5076,7 +4983,6 @@ exports.selectReceiveAddress = selectReceiveAddress; exports.selectRecentTransactions = selectRecentTransactions; exports.selectResolvingUris = selectResolvingUris; exports.selectSearchBarFocused = selectSearchBarFocused; -exports.selectSearchDownloadUris = selectSearchDownloadUris; exports.selectSearchOptions = selectSearchOptions; exports.selectSearchState = selectState; exports.selectSearchSuggestions = selectSearchSuggestions; diff --git a/package.json b/package.json index ca6b815..b8214b4 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "main": "dist/bundle.es.js", "module": "dist/bundle.es.js", "scripts": { - "build": "NODE_ENV=production rollup --config", + "build": "cross-env NODE_ENV=production rollup --config", "dev": "rollup --config --watch", "precommit": "flow check && lint-staged", "lint": "eslint 'src/**/*.js' --fix", @@ -40,6 +40,7 @@ "babel-plugin-transform-flow-comments": "^6.17.0", "babel-preset-env": "^1.6.1", "babel-preset-stage-2": "^6.18.0", + "cross-env": "^5.2.0", "eslint": "^5.16.0", "eslint-config-standard": "^12.0.0", "eslint-config-standard-jsx": "^6.0.2", diff --git a/src/index.js b/src/index.js index 1370c3c..754aa87 100644 --- a/src/index.js +++ b/src/index.js @@ -215,7 +215,6 @@ export { selectFileInfosDownloaded, selectDownloadingFileInfos, selectTotalDownloadProgress, - selectSearchDownloadUris, selectFileListDownloadedSort, selectFileListPublishedSort, selectDownloadedUris, diff --git a/src/lbryURI.js b/src/lbryURI.js index c22dbbf..9006055 100644 --- a/src/lbryURI.js +++ b/src/lbryURI.js @@ -1,6 +1,6 @@ // @flow const isProduction = process.env.NODE_ENV === 'production'; -const channelNameMinLength = 1; +const channelNameMinLength = 2; const claimIdMaxLength = 40; // see https://spec.lbry.com/#urls @@ -75,7 +75,7 @@ export function parseURI(URL: string, requireProto: boolean = false): LbryUrlObj const includesChannel = streamNameOrChannelName.startsWith('@'); const isChannel = streamNameOrChannelName.startsWith('@') && !possibleStreamName; - const channelName = includesChannel && streamNameOrChannelName.slice(1); + const channelName = includesChannel && streamNameOrChannelName; if (includesChannel) { if (!channelName) { diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index 34bd4ed..0a0975b 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -112,7 +112,7 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): const pendingById: { [string]: Claim } = Object.assign({}, state.pendingById); claims.forEach((claim: Claim) => { - const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id }); + const uri = buildURI({ streamName: claim.name, streamClaimId: claim.claim_id }); if (claim.type && claim.type.match(/claim|update/)) { if (claim.confirmations < 1) { diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 26cbc7b..9fbea4d 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -458,7 +458,7 @@ export const makeSelectRecommendedContentForUri = (uri: string) => if (claim) { // If we are at a vanity uri, build the full uri so we can properly filter const currentUri = atVanityURI - ? buildURI({ claimId: claim.claim_id, claimName: claim.name }) + ? buildURI({ streamClaimId: claim.claim_id, streamName: claim.name }) : uri; const { title } = claim.value; diff --git a/src/redux/selectors/file_info.js b/src/redux/selectors/file_info.js index c36bd76..d805eff 100644 --- a/src/redux/selectors/file_info.js +++ b/src/redux/selectors/file_info.js @@ -132,106 +132,6 @@ export const selectTotalDownloadProgress = createSelector( } ); -export const selectSearchDownloadUris = query => - createSelector( - selectFileInfosDownloaded, - selectClaimsById, - (fileInfos, claimsById) => { - if (!query || !fileInfos.length) { - return null; - } - - const queryParts = query.toLowerCase().split(' '); - const searchQueryDictionary = {}; - queryParts.forEach(subQuery => { - searchQueryDictionary[subQuery] = subQuery; - }); - - const arrayContainsQueryPart = array => { - for (let i = 0; i < array.length; i += 1) { - const subQuery = array[i]; - if (searchQueryDictionary[subQuery]) { - return true; - } - } - return false; - }; - - const downloadResultsFromQuery = []; - fileInfos.forEach(fileInfo => { - const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo; - const { author, description, title } = metadata; - - if (channelName) { - const lowerCaseChannel = channelName.toLowerCase(); - const strippedOutChannelName = lowerCaseChannel.slice(1); // trim off the @ - if (searchQueryDictionary[channelName] || searchQueryDictionary[strippedOutChannelName]) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - const nameParts = claimName.toLowerCase().split('-'); - if (arrayContainsQueryPart(nameParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - - if (title) { - const titleParts = title.toLowerCase().split(' '); - if (arrayContainsQueryPart(titleParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - if (author) { - const authorParts = author.toLowerCase().split(' '); - if (arrayContainsQueryPart(authorParts)) { - downloadResultsFromQuery.push(fileInfo); - return; - } - } - - if (description) { - const descriptionParts = description.toLowerCase().split(' '); - if (arrayContainsQueryPart(descriptionParts)) { - downloadResultsFromQuery.push(fileInfo); - } - } - }); - - return downloadResultsFromQuery.length - ? downloadResultsFromQuery.map(fileInfo => { - const { - channel_name: channelName, - claim_id: claimId, - claim_name: claimName, - } = fileInfo; - - const uriParams = {}; - - if (channelName) { - const claim = claimsById[claimId]; - if (claim && claim.signing_channel) { - uriParams.claimId = claim.signing_channel.claim_id; - } else { - uriParams.claimId = claimId; - } - uriParams.channelName = channelName; - uriParams.contentName = claimName; - } else { - uriParams.claimId = claimId; - uriParams.claimName = claimName; - } - - const uri = buildURI(uriParams); - return uri; - }) - : null; - } - ); - export const selectFileListPublishedSort = createSelector( selectState, state => state.fileListPublishedSort diff --git a/src/redux/selectors/publish.js b/src/redux/selectors/publish.js index 8842e30..ac468c9 100644 --- a/src/redux/selectors/publish.js +++ b/src/redux/selectors/publish.js @@ -35,13 +35,13 @@ export const selectIsStillEditing = createSelector( const { isChannel: currentIsChannel, - channelName: currentClaimName, - streamName: currentContentName, + streamName: currentClaimName, + channelName: currentContentName, } = parseURI(uri); const { isChannel: editIsChannel, - channelName: editClaimName, - streamName: editContentName, + streamName: editClaimName, + channelName: editContentName, } = parseURI(editingURI); // Depending on the previous/current use of a channel, we need to compare different things @@ -58,8 +58,8 @@ export const selectMyClaimForUri = createSelector( selectClaimsById, selectMyClaimsWithoutChannels, ({ editingURI, uri }, isStillEditing, claimsById, myClaims) => { - const { contentName, claimName } = parseURI(uri); - const { claimId: editClaimId } = parseURI(editingURI); + const { channelName: contentName, streamName: claimName } = parseURI(uri); + const { streamClaimId: editClaimId } = parseURI(editingURI); // If isStillEditing // They clicked "edit" from the file page @@ -110,14 +110,14 @@ export const selectTakeOverAmount = createSelector( const claimForShortUri = claimsByUri[shortUri]; if (!myClaimForUri && claimForShortUri) { - return claimForShortUri.effective_amount; + return claimForShortUri.meta.effective_amount; } else if (myClaimForUri && claimForShortUri) { // https://github.com/lbryio/lbry/issues/1476 // We should check the current effective_amount on my claim to see how much additional lbc // is needed to win the claim. Currently this is not possible during a takeover. // With this, we could say something like, "You have x lbc in support, if you bid y additional LBC you will control the claim" // For now just ignore supports. We will just show the winning claim's bid amount - return claimForShortUri.effective_amount || claimForShortUri.amount; + return claimForShortUri.meta.effective_amount || claimForShortUri.amount; } return null; diff --git a/yarn.lock b/yarn.lock index 156e422..eed6546 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1418,6 +1418,14 @@ cosmiconfig@^4.0.0: parse-json "^4.0.0" require-from-string "^2.0.1" +cross-env@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2" + integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg== + dependencies: + cross-spawn "^6.0.5" + is-windows "^1.0.0" + cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -2886,7 +2894,7 @@ is-utf8@^0.2.0: resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= -is-windows@^1.0.2: +is-windows@^1.0.0, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==