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 = () => {
|
||||
const { navigation, uri, shortUrl } = this.props;
|
||||
const { claim, navigation, uri, shortUrl } = this.props;
|
||||
const normalizedUri = normalizeURI(uri);
|
||||
if (NativeModules.Firebase) {
|
||||
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() {
|
||||
|
@ -124,7 +124,13 @@ class FileItem extends React.PureComponent {
|
|||
style={discoverStyle.channelName}
|
||||
text={channelName}
|
||||
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) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
|
||||
} 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}
|
||||
text={channel}
|
||||
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}
|
||||
numberOfLines={1}
|
||||
text={claim.name}
|
||||
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri))}
|
||||
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri), null, false, claim.permanent_url)}
|
||||
/>
|
||||
)}
|
||||
{tags && (
|
||||
|
|
|
@ -46,30 +46,30 @@ import { selectDrawerStack } from 'redux/selectors/drawer';
|
|||
import FilePage from './view';
|
||||
|
||||
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 {
|
||||
balance: selectBalance(state),
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
channels: selectMyChannelClaims(state),
|
||||
claim: makeSelectClaimForUri(selectProps.uri)(state),
|
||||
claim: makeSelectClaimForUri(contentUri)(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
|
||||
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
|
||||
// obscureNsfw: !selectShowNsfw(state),
|
||||
// tab: makeSelectCurrentParam('tab')(state),
|
||||
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(contentUri)(state),
|
||||
contentType: makeSelectContentTypeForUri(contentUri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(contentUri)(state),
|
||||
metadata: makeSelectMetadataForUri(contentUri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(contentUri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
||||
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
||||
position: makeSelectContentPositionForUri(selectProps.uri)(state),
|
||||
channelUri: makeSelectChannelForClaimUri(contentUri, true)(state),
|
||||
position: makeSelectContentPositionForUri(contentUri)(state),
|
||||
purchasedUris: selectPurchasedUris(state),
|
||||
failedPurchaseUris: selectFailedPurchaseUris(state),
|
||||
myClaimUris: selectMyClaimUrisWithoutChannels(state),
|
||||
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
|
||||
title: makeSelectTitleForUri(selectProps.uri)(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(contentUri)(state),
|
||||
title: makeSelectTitleForUri(contentUri)(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -999,7 +999,13 @@ class FilePage extends React.PureComponent {
|
|||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
|
||||
navigateToUri(
|
||||
navigation,
|
||||
normalizeURI(shortChannelUri || fullChannelUri),
|
||||
null,
|
||||
false,
|
||||
fullChannelUri
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -31,7 +31,7 @@ function getRouteForSpecialUri(uri) {
|
|||
return targetRoute;
|
||||
}
|
||||
|
||||
export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
||||
export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack, fullUri) {
|
||||
if (uri.startsWith('lbry://?')) {
|
||||
dispatch(NavigationActions.navigate({ routeName: getRouteForSpecialUri(uri) }));
|
||||
return;
|
||||
|
@ -45,7 +45,7 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
|||
uriVars = parseUriVars(uriVarsStr);
|
||||
}
|
||||
|
||||
const params = { uri, uriVars };
|
||||
const params = { uri, uriVars, fullUri: fullUri };
|
||||
|
||||
if (!isNavigatingBack) {
|
||||
dispatch(doPushDrawerStack(uri));
|
||||
|
@ -108,7 +108,7 @@ function parseUriVars(vars) {
|
|||
return uriVars;
|
||||
}
|
||||
|
||||
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack) {
|
||||
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri) {
|
||||
if (!navigation) {
|
||||
return;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
|
|||
}
|
||||
|
||||
const { store } = window;
|
||||
const params = Object.assign({ uri, uriVars }, additionalParams);
|
||||
const params = Object.assign({ uri, uriVars, fullUri: fullUri }, additionalParams);
|
||||
if (navigation.state.routeName === 'File') {
|
||||
const stackAction = StackActions.replace({ routeName: 'File', newKey: uri, params });
|
||||
navigation.dispatch(stackAction);
|
||||
|
|
Loading…
Reference in a new issue