avoid re-resolving a claim when navigation to a short / canonical URL #79
6 changed files with 43 additions and 25 deletions
|
@ -30,12 +30,12 @@ class FileItem extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToFileUri = () => {
|
navigateToFileUri = () => {
|
||||||
const { navigation, uri, shortUrl } = this.props;
|
const { claim, navigation, uri, shortUrl } = this.props;
|
||||||
const normalizedUri = normalizeURI(uri);
|
const normalizedUri = normalizeURI(uri);
|
||||||
if (NativeModules.Firebase) {
|
if (NativeModules.Firebase) {
|
||||||
NativeModules.Firebase.track('explore_click', { uri: normalizedUri, short_url: shortUrl });
|
NativeModules.Firebase.track('explore_click', { uri: normalizedUri, short_url: shortUrl });
|
||||||
}
|
}
|
||||||
navigateToUri(navigation, shortUrl || uri);
|
navigateToUri(navigation, shortUrl || uri, null, false, claim ? claim.permanent_url : null);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -124,7 +124,13 @@ class FileItem extends React.PureComponent {
|
||||||
style={discoverStyle.channelName}
|
style={discoverStyle.channelName}
|
||||||
text={channelName}
|
text={channelName}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
navigateToUri(
|
||||||
|
navigation,
|
||||||
|
normalizeURI(shortChannelUri || fullChannelUri),
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
fullChannelUri
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -59,7 +59,7 @@ class FileListItem extends React.PureComponent {
|
||||||
if (featuredResult && !claim) {
|
if (featuredResult && !claim) {
|
||||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
|
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
|
||||||
} else {
|
} else {
|
||||||
navigateToUri(navigation, shortUrl || uri, { autoplay });
|
navigateToUri(navigation, shortUrl || uri, { autoplay }, false, claim ? claim.permanent_url : null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,7 +198,13 @@ class FileListItem extends React.PureComponent {
|
||||||
style={fileListStyle.publisher}
|
style={fileListStyle.publisher}
|
||||||
text={channel}
|
text={channel}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
navigateToUri(
|
||||||
|
navigation,
|
||||||
|
normalizeURI(shortChannelUri || fullChannelUri),
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
fullChannelUri
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SuggestedSubscriptionItem extends React.PureComponent {
|
||||||
style={subscriptionsStyle.suggestedItemName}
|
style={subscriptionsStyle.suggestedItemName}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
text={claim.name}
|
text={claim.name}
|
||||||
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri))}
|
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri), null, false, claim.permanent_url)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{tags && (
|
{tags && (
|
||||||
|
|
|
@ -46,30 +46,30 @@ import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||||
import FilePage from './view';
|
import FilePage from './view';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
const selectProps = { uri: props.navigation.state.params.uri };
|
const { uri, fullUri } = props.navigation.state.params;
|
||||||
|
const contentUri = fullUri || uri;
|
||||||
|
const selectProps = { uri: contentUri };
|
||||||
return {
|
return {
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||||
channels: selectMyChannelClaims(state),
|
channels: selectMyChannelClaims(state),
|
||||||
claim: makeSelectClaimForUri(selectProps.uri)(state),
|
claim: makeSelectClaimForUri(contentUri)(state),
|
||||||
drawerStack: selectDrawerStack(state),
|
drawerStack: selectDrawerStack(state),
|
||||||
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
|
isResolvingUri: makeSelectIsUriResolving(contentUri)(state),
|
||||||
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
|
contentType: makeSelectContentTypeForUri(contentUri)(state),
|
||||||
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
|
costInfo: makeSelectCostInfoForUri(contentUri)(state),
|
||||||
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
|
metadata: makeSelectMetadataForUri(contentUri)(state),
|
||||||
// obscureNsfw: !selectShowNsfw(state),
|
fileInfo: makeSelectFileInfoForUri(contentUri)(state),
|
||||||
// tab: makeSelectCurrentParam('tab')(state),
|
|
||||||
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
|
||||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
||||||
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
channelUri: makeSelectChannelForClaimUri(contentUri, true)(state),
|
||||||
position: makeSelectContentPositionForUri(selectProps.uri)(state),
|
position: makeSelectContentPositionForUri(contentUri)(state),
|
||||||
purchasedUris: selectPurchasedUris(state),
|
purchasedUris: selectPurchasedUris(state),
|
||||||
failedPurchaseUris: selectFailedPurchaseUris(state),
|
failedPurchaseUris: selectFailedPurchaseUris(state),
|
||||||
myClaimUris: selectMyClaimUrisWithoutChannels(state),
|
myClaimUris: selectMyClaimUrisWithoutChannels(state),
|
||||||
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
|
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state),
|
||||||
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
|
thumbnail: makeSelectThumbnailForUri(contentUri)(state),
|
||||||
title: makeSelectTitleForUri(selectProps.uri)(state),
|
title: makeSelectTitleForUri(contentUri)(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -999,7 +999,13 @@ class FilePage extends React.PureComponent {
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
ellipsizeMode={'tail'}
|
ellipsizeMode={'tail'}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
navigateToUri(
|
||||||
|
navigation,
|
||||||
|
normalizeURI(shortChannelUri || fullChannelUri),
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
fullChannelUri
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -31,7 +31,7 @@ function getRouteForSpecialUri(uri) {
|
||||||
return targetRoute;
|
return targetRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack, fullUri) {
|
||||||
if (uri.startsWith('lbry://?')) {
|
if (uri.startsWith('lbry://?')) {
|
||||||
dispatch(NavigationActions.navigate({ routeName: getRouteForSpecialUri(uri) }));
|
dispatch(NavigationActions.navigate({ routeName: getRouteForSpecialUri(uri) }));
|
||||||
return;
|
return;
|
||||||
|
@ -45,7 +45,7 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
||||||
uriVars = parseUriVars(uriVarsStr);
|
uriVars = parseUriVars(uriVarsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = { uri, uriVars };
|
const params = { uri, uriVars, fullUri: fullUri };
|
||||||
|
|
||||||
if (!isNavigatingBack) {
|
if (!isNavigatingBack) {
|
||||||
dispatch(doPushDrawerStack(uri));
|
dispatch(doPushDrawerStack(uri));
|
||||||
|
@ -108,7 +108,7 @@ function parseUriVars(vars) {
|
||||||
return uriVars;
|
return uriVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack) {
|
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri) {
|
||||||
if (!navigation) {
|
if (!navigation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
|
||||||
}
|
}
|
||||||
|
|
||||||
const { store } = window;
|
const { store } = window;
|
||||||
const params = Object.assign({ uri, uriVars }, additionalParams);
|
const params = Object.assign({ uri, uriVars, fullUri: fullUri }, additionalParams);
|
||||||
if (navigation.state.routeName === 'File') {
|
if (navigation.state.routeName === 'File') {
|
||||||
const stackAction = StackActions.replace({ routeName: 'File', newKey: uri, params });
|
const stackAction = StackActions.replace({ routeName: 'File', newKey: uri, params });
|
||||||
navigation.dispatch(stackAction);
|
navigation.dispatch(stackAction);
|
||||||
|
|
Loading…
Reference in a new issue