move to canonical_url and allow pasting lbry.tv links in wunderbar
This commit is contained in:
parent
fd2bb3dc1f
commit
1c2347921a
10 changed files with 63 additions and 44 deletions
|
@ -43,7 +43,7 @@ function ChannelContent(props: Props) {
|
||||||
{!channelIsMine && <HiddenNsfwClaims className="card__subtitle" uri={uri} />}
|
{!channelIsMine && <HiddenNsfwClaims className="card__subtitle" uri={uri} />}
|
||||||
|
|
||||||
{hasContent && !channelIsBlocked && (
|
{hasContent && !channelIsBlocked && (
|
||||||
<ClaimList header={false} uris={claimsInChannel.map(claim => claim.permanent_url)} />
|
<ClaimList header={false} uris={claimsInChannel.map(claim => claim.canonical_url)} />
|
||||||
)}
|
)}
|
||||||
{!channelIsBlocked && (
|
{!channelIsBlocked && (
|
||||||
<Paginate
|
<Paginate
|
||||||
|
|
|
@ -111,13 +111,13 @@ export default function ClaimList(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{injectedItem && <div>{injectedItem}</div>}
|
||||||
|
|
||||||
{urisLength > 0 && (
|
{urisLength > 0 && (
|
||||||
<ul className="ul--no-style">
|
<ul className="ul--no-style">
|
||||||
{sortedUris.map((uri, index) => (
|
{sortedUris.map((uri, index) => (
|
||||||
<React.Fragment key={uri}>
|
<ClaimPreview key={uri} uri={uri} type={type} showUserBlocked={showHiddenByUser} />
|
||||||
<ClaimPreview uri={uri} type={type} showUserBlocked={showHiddenByUser} />
|
|
||||||
{index === 4 && injectedItem && injectedItem}
|
|
||||||
</React.Fragment>
|
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as SETTINGS from 'constants/settings';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
doClaimSearch,
|
doClaimSearch,
|
||||||
selectClaimSearchByQuery,
|
selectClaimSearchByQueryCanonical,
|
||||||
selectFetchingClaimSearch,
|
selectFetchingClaimSearch,
|
||||||
doToggleTagFollow,
|
doToggleTagFollow,
|
||||||
selectBlockedChannels,
|
selectBlockedChannels,
|
||||||
|
@ -12,7 +12,7 @@ import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import ClaimListDiscover from './view';
|
import ClaimListDiscover from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
claimSearchByQuery: selectClaimSearchByQuery(state),
|
claimSearchByQuery: selectClaimSearchByQueryCanonical(state),
|
||||||
loading: selectFetchingClaimSearch(state),
|
loading: selectFetchingClaimSearch(state),
|
||||||
subscribedChannels: selectSubscriptions(state),
|
subscribedChannels: selectSubscriptions(state),
|
||||||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
|
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
|
||||||
|
|
|
@ -23,20 +23,20 @@ import { push } from 'connected-react-router';
|
||||||
import ClaimPreview from './view';
|
import ClaimPreview from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
pending: makeSelectClaimIsPending(props.uri)(state),
|
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: props.uri && makeSelectClaimForUri(props.uri)(state),
|
||||||
obscureNsfw: !selectShowMatureContent(state),
|
obscureNsfw: !selectShowMatureContent(state),
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: props.uri && makeSelectClaimIsMine(props.uri)(state),
|
||||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
|
||||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
thumbnail: props.uri && makeSelectThumbnailForUri(props.uri)(state),
|
||||||
title: makeSelectTitleForUri(props.uri)(state),
|
title: props.uri && makeSelectTitleForUri(props.uri)(state),
|
||||||
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
|
nsfw: props.uri && makeSelectClaimIsNsfw(props.uri)(state),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
filteredOutpoints: selectFilteredOutpoints(state),
|
filteredOutpoints: selectFilteredOutpoints(state),
|
||||||
blockedChannelUris: selectBlockedChannels(state),
|
blockedChannelUris: selectBlockedChannels(state),
|
||||||
hasVisitedUri: makeSelectHasVisitedUri(props.uri)(state),
|
hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state),
|
||||||
channelIsBlocked: selectChannelIsBlocked(props.uri)(state),
|
channelIsBlocked: props.uri && selectChannelIsBlocked(props.uri)(state),
|
||||||
isSubscribed: makeSelectIsSubscribed(props.uri, true)(state),
|
isSubscribed: props.uri && makeSelectIsSubscribed(props.uri, true)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -78,13 +78,15 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
const includeChannelTooltip = type !== 'inline' && type !== 'tooltip';
|
const includeChannelTooltip = type !== 'inline' && type !== 'tooltip';
|
||||||
const hideActions = type === 'small' || type === 'tooltip';
|
const hideActions = type === 'small' || type === 'tooltip';
|
||||||
|
|
||||||
let isValid;
|
|
||||||
let name;
|
let name;
|
||||||
try {
|
let isValid = false;
|
||||||
({ claimName: name } = parseURI(uri));
|
if (uri) {
|
||||||
isValid = true;
|
try {
|
||||||
} catch (e) {
|
({ claimName: name } = parseURI(uri));
|
||||||
isValid = false;
|
isValid = true;
|
||||||
|
} catch (e) {
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isChannel = isValid ? parseURI(uri).isChannel : false;
|
const isChannel = isValid ? parseURI(uri).isChannel : false;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectShortUrlForUri, doToast } from 'lbry-redux';
|
import { makeSelectCanonicalUrlForUri, doToast } from 'lbry-redux';
|
||||||
import ClaimUri from './view';
|
import ClaimUri from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
|
shortUrl: makeSelectCanonicalUrlForUri(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -11,6 +11,9 @@ import Tag from 'component/tag';
|
||||||
|
|
||||||
const L_KEY_CODE = 76;
|
const L_KEY_CODE = 76;
|
||||||
const ESC_KEY_CODE = 27;
|
const ESC_KEY_CODE = 27;
|
||||||
|
const WEB_DEV_PREFIX = 'http://localhost:1337/';
|
||||||
|
const WEB_PROD_PREFIX = 'https://beta.lbry.tv/';
|
||||||
|
const SEARCH_PREFIX = `$/${PAGES.SEARCH}q=`;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
searchQuery: ?string,
|
searchQuery: ?string,
|
||||||
|
@ -95,12 +98,37 @@ class WunderBar extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
handleSubmit(value: string, suggestion?: { value: string, type: string }) {
|
handleSubmit(value: string, suggestion?: { value: string, type: string }) {
|
||||||
const { onSubmit, onSearch, doShowSnackBar, history } = this.props;
|
const { onSubmit, onSearch, doShowSnackBar, history } = this.props;
|
||||||
|
let query = value.trim();
|
||||||
|
|
||||||
const query = value.trim();
|
|
||||||
const showSnackError = () => {
|
const showSnackError = () => {
|
||||||
doShowSnackBar('Invalid LBRY URL entered. Only A-Z, a-z, 0-9, and "-" allowed.');
|
doShowSnackBar('Invalid LBRY URL entered. Only A-Z, a-z, 0-9, and "-" allowed.');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Allow copying a lbry.tv url and pasting it into the search bar
|
||||||
|
const includesLbryTvProd = query.includes(WEB_PROD_PREFIX);
|
||||||
|
const includesLbryTvDev = query.includes(WEB_DEV_PREFIX);
|
||||||
|
const wasCopiedFromWeb = includesLbryTvDev || includesLbryTvProd;
|
||||||
|
|
||||||
|
if (wasCopiedFromWeb) {
|
||||||
|
if (includesLbryTvDev) {
|
||||||
|
query = query.slice(WEB_DEV_PREFIX.length);
|
||||||
|
} else {
|
||||||
|
query = query.slice(WEB_PROD_PREFIX.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query.replace(/:/g, '#');
|
||||||
|
|
||||||
|
if (query.includes(SEARCH_PREFIX)) {
|
||||||
|
query = query.slice(SEARCH_PREFIX.length);
|
||||||
|
onSearch(query);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
query = `lbry://${query}`;
|
||||||
|
onSubmit(query);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// User selected a suggestion
|
// User selected a suggestion
|
||||||
if (suggestion) {
|
if (suggestion) {
|
||||||
if (suggestion.type === SEARCH_TYPES.SEARCH) {
|
if (suggestion.type === SEARCH_TYPES.SEARCH) {
|
||||||
|
|
|
@ -5,26 +5,23 @@ import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectIsUriResolving,
|
makeSelectIsUriResolving,
|
||||||
makeSelectTotalPagesForChannel,
|
makeSelectTotalPagesForChannel,
|
||||||
buildURI,
|
normalizeURI,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { selectBlackListedOutpoints } from 'lbryinc';
|
import { selectBlackListedOutpoints } from 'lbryinc';
|
||||||
import ShowPage from './view';
|
import ShowPage from './view';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
const { pathname } = props.location;
|
const { pathname } = props.location;
|
||||||
const urlParts = pathname.split('/');
|
// Remove the leading "/" added by the browser
|
||||||
const claimName = urlParts[1];
|
const path = pathname.slice(1).replace(/:/g, '#');
|
||||||
const claimId = urlParts[2];
|
const uri = normalizeURI(path);
|
||||||
|
|
||||||
// claimName and claimId come from the url `lbry.tv/{claimName}/{claimId}"
|
|
||||||
const uri = buildURI({ contentName: claimName, claimId: claimId });
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
claim: makeSelectClaimForUri(uri)(state),
|
claim: makeSelectClaimForUri(uri)(state),
|
||||||
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
isResolvingUri: makeSelectIsUriResolving(uri)(state),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state),
|
totalPages: makeSelectTotalPagesForChannel(uri, PAGE_SIZE)(state),
|
||||||
uri: uri,
|
uri,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ $border-color--dark: var(--dm-color-04);
|
||||||
|
|
||||||
.claim-preview--injected,
|
.claim-preview--injected,
|
||||||
.claim-preview {
|
.claim-preview {
|
||||||
border-bottom: 1px solid $border-color;
|
border-top: 1px solid $border-color;
|
||||||
|
|
||||||
&:only-of-type {
|
&:only-of-type {
|
||||||
border: none;
|
border: none;
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { parseURI } from 'lbry-redux';
|
|
||||||
|
|
||||||
const LBRY_INC_DOMAINS = ['lbry.io', 'lbry.com', 'lbry.tv', 'lbry.tech', 'lbry.fund', 'spee.ch'];
|
const LBRY_INC_DOMAINS = ['lbry.io', 'lbry.com', 'lbry.tv', 'lbry.tech', 'lbry.fund', 'spee.ch'];
|
||||||
|
|
||||||
export const formatLbryUriForWeb = (uri: string) => {
|
export const formatLbryUriForWeb = (uri: string) => {
|
||||||
const { claimName, claimId } = parseURI(uri);
|
return uri.replace('lbry://', '/').replace(/#/g, ':');
|
||||||
|
|
||||||
let webUrl = `/${claimName}`;
|
|
||||||
if (claimId) {
|
|
||||||
webUrl += `/${claimId}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return webUrl;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatPathForWeb = (path: string) => {
|
export const formatPathForWeb = (path: string) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue