handle opening urls in lite mode
This commit is contained in:
parent
40e2080c52
commit
6116bd3809
9 changed files with 81 additions and 32 deletions
2
android
2
android
|
@ -1 +1 @@
|
|||
Subproject commit 1a5c8b7ba7d4f21c9258361aae216d3c6a3cb20d
|
||||
Subproject commit b7b6c05bd3a61c1cec09a08f1b5c413a68597026
|
|
@ -15,7 +15,7 @@
|
|||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"gfycat-style-urls": "^1.0.3",
|
||||
"lbry-redux": "lbryio/lbry-redux#f36b91496b3852e3d032b6d360b14d5fafbc07a9",
|
||||
"lbry-redux": "lbryio/lbry-redux#f6e99498d2bc5b3f07e1e2b6f668a1a48de35047",
|
||||
"lbryinc": "lbryio/lbryinc#1fc104c2d29d1d3975234c3606e848eaa28e1b6e",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
|
|
|
@ -39,10 +39,14 @@ class ClaimResultItem extends React.PureComponent {
|
|||
}
|
||||
|
||||
onPressHandler = () => {
|
||||
const { autoplay, navigation, result, setPlayerVisible } = this.props;
|
||||
const { autoplay, navigation, result, urlOpenHandler, setPlayerVisible } = this.props;
|
||||
const { claimId, name } = result;
|
||||
const url = normalizeURI(`${name}#${claimId}`);
|
||||
navigateToUri(navigation, url, { autoplay }, false, url, setPlayerVisible);
|
||||
if (urlOpenHandler) {
|
||||
urlOpenHandler(url);
|
||||
} else {
|
||||
navigateToUri(navigation, url, { autoplay }, false, url, setPlayerVisible);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
@ -15,7 +15,13 @@ const RESULT_SIZE = 16;
|
|||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isSearching: selectIsSearching(state),
|
||||
recommendedContent: makeSelectResolvedRecommendedContentForUri(props.uri, RESULT_SIZE)(state),
|
||||
recommendedContent: makeSelectResolvedRecommendedContentForUri(
|
||||
props.uri,
|
||||
RESULT_SIZE,
|
||||
props.claimId,
|
||||
props.claimName,
|
||||
props.title,
|
||||
)(state),
|
||||
resolvingUris: selectResolvingUris(state),
|
||||
showNsfwContent: selectShowNsfw(state),
|
||||
});
|
||||
|
@ -26,7 +32,4 @@ const perform = dispatch => ({
|
|||
dispatch(doResolvedSearch(query, RESULT_SIZE, undefined, true, { related_to: claimId }, nsfw)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform,
|
||||
)(RelatedContent);
|
||||
export default connect(select, perform)(RelatedContent);
|
||||
|
|
|
@ -22,7 +22,7 @@ export default class RelatedContent extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { isSearching, recommendedContent, navigation, uri, fullUri } = this.props;
|
||||
const { isSearching, recommendedContent, navigation, urlOpenHandler, uri, fullUri } = this.props;
|
||||
|
||||
return (
|
||||
<View style={relatedContentStyle.container}>
|
||||
|
@ -33,6 +33,7 @@ export default class RelatedContent extends React.PureComponent {
|
|||
<ClaimResultItem
|
||||
style={fileListStyle.item}
|
||||
uri={result ? normalizeURI(`${result.name}#${result.claimId}`) : null}
|
||||
urlOpenHandler={urlOpenHandler}
|
||||
key={result.claimId}
|
||||
result={result}
|
||||
navigation={navigation}
|
||||
|
|
|
@ -187,8 +187,9 @@ class UriBar extends React.PureComponent {
|
|||
handleNavigationButtonPress = () => {
|
||||
const { navigation } = this.props;
|
||||
if (!navigation.openDrawer) {
|
||||
Alert.alert(__('Switch to full mode'),
|
||||
'This will reload the app in full mode. Do you wish to continue?',
|
||||
Alert.alert(
|
||||
__('Stop watching?'),
|
||||
'The LBRY service is still loading stuff in the background. Would you like to continue?',
|
||||
[
|
||||
{ text: __('No') },
|
||||
{
|
||||
|
@ -196,16 +197,19 @@ class UriBar extends React.PureComponent {
|
|||
onPress: () => {
|
||||
const resetAction = StackActions.reset({
|
||||
index: 0,
|
||||
actions: [NavigationActions.navigate({ routeName: 'Splash' })],
|
||||
actions: [
|
||||
NavigationActions.navigate({ routeName: 'Splash', params: { resetUrl: 'lbry://?subscriptions' } }),
|
||||
],
|
||||
});
|
||||
navigation.dispatch(resetAction);
|
||||
},
|
||||
},
|
||||
]);
|
||||
],
|
||||
);
|
||||
} else {
|
||||
navigation.openDrawer();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
|
|
|
@ -28,6 +28,7 @@ import { decode, formatLbryUrlForWeb, navigateToUri } from 'utils/helper';
|
|||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import uriBarStyle from 'styles/uriBar';
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
|
||||
// This page will only be used for playing audio / video content from a remote stream URL
|
||||
class LiteFilePage extends React.PureComponent {
|
||||
|
@ -40,10 +41,11 @@ class LiteFilePage extends React.PureComponent {
|
|||
state = {
|
||||
channelName: null,
|
||||
channelUrl: null,
|
||||
contentTitle: null,
|
||||
title: null,
|
||||
fullscreenMode: false,
|
||||
playerHeight: null,
|
||||
isLandscape: false,
|
||||
sdkReady: false, // TODO: progressively enable features (e.g. tip) when sdk is ready
|
||||
showRecommended: false,
|
||||
viewCount: 0,
|
||||
};
|
||||
|
@ -104,11 +106,32 @@ class LiteFilePage extends React.PureComponent {
|
|||
NativeModules.UtilityModule.shareUrl(shareUrl);
|
||||
};
|
||||
|
||||
handleOpenUrl = url => {
|
||||
const { navigation } = this.props;
|
||||
Alert.alert(
|
||||
__('Stop watching?'),
|
||||
'The LBRY service is still loading stuff in the background. Would you like to continue?',
|
||||
[
|
||||
{ text: __('No') },
|
||||
{
|
||||
text: __('Yes'),
|
||||
onPress: () => {
|
||||
const resetAction = StackActions.reset({
|
||||
index: 0,
|
||||
actions: [NavigationActions.navigate({ routeName: 'Splash', params: { resetUrl: url } })],
|
||||
});
|
||||
navigation.dispatch(resetAction);
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
};
|
||||
|
||||
componentDidUpdate() {
|
||||
const { navigation } = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
|
||||
if (!this.state.contentTitle) {
|
||||
if (!this.state.title) {
|
||||
const params = parseQueryParams(uri);
|
||||
const { channelUrl, contentTitle } = params;
|
||||
const channelName = channelUrl ? parseURI(decode(channelUrl)).claimName : null;
|
||||
|
@ -124,7 +147,7 @@ class LiteFilePage extends React.PureComponent {
|
|||
|
||||
render() {
|
||||
const { navigation, rewardedContentClaimIds } = this.props;
|
||||
const { channelName, channelUrl, title, viewCount } = this.state;
|
||||
const { channelName, channelUrl, title, sdkReady, viewCount } = this.state;
|
||||
const { uri } = navigation.state.params;
|
||||
const { claimName, claimId } = parseURI(uri);
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claimId);
|
||||
|
@ -212,10 +235,15 @@ class LiteFilePage extends React.PureComponent {
|
|||
<Text style={filePageStyle.largeButtonText}>{__('Share')}</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity style={filePageStyle.largeButton} onPress={() => this.setState({ showTipView: true })}>
|
||||
<Icon name={'gift'} size={16} style={filePageStyle.largeButtonIcon} />
|
||||
<Text style={filePageStyle.largeButtonText}>{__('Tip')}</Text>
|
||||
</TouchableOpacity>
|
||||
{sdkReady && (
|
||||
<TouchableOpacity
|
||||
style={filePageStyle.largeButton}
|
||||
onPress={() => this.setState({ showTipView: true })}
|
||||
>
|
||||
<Icon name={'gift'} size={16} style={filePageStyle.largeButtonIcon} />
|
||||
<Text style={filePageStyle.largeButtonText}>{__('Tip')}</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View style={filePageStyle.channelRow}>
|
||||
|
@ -227,9 +255,7 @@ class LiteFilePage extends React.PureComponent {
|
|||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(channelUrl), null, false, null, false);
|
||||
}}
|
||||
onPress={() => this.handleOpenUrl(channelUrl)}
|
||||
/>
|
||||
)}
|
||||
{!channelName && (
|
||||
|
@ -243,7 +269,15 @@ class LiteFilePage extends React.PureComponent {
|
|||
<View onLayout={this.setRelatedContentPosition} />
|
||||
|
||||
{this.state.showRecommended && (
|
||||
<RelatedContent navigation={navigation} claimId={claimId} title={title} uri={uri} fullUri={uri} />
|
||||
<RelatedContent
|
||||
navigation={navigation}
|
||||
claimId={claimId}
|
||||
claimName={claimName}
|
||||
title={title}
|
||||
urlOpenHandler={this.handleOpenUrl}
|
||||
uri={uri}
|
||||
fullUri={uri}
|
||||
/>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
|
|
@ -338,19 +338,22 @@ class SplashScreen extends React.PureComponent {
|
|||
componentDidMount() {
|
||||
NativeModules.Firebase.track('app_launch', null);
|
||||
NativeModules.Firebase.setCurrentScreen('Splash');
|
||||
const { navigation } = this.props;
|
||||
const { resetUrl } = navigation.state.params;
|
||||
const isResetUrlSet = !!resetUrl;
|
||||
|
||||
this.props.fetchRewardedContent();
|
||||
Linking.getInitialURL().then(url => {
|
||||
let liteMode;
|
||||
if (url) {
|
||||
liteMode = url.indexOf('liteMode=1') > -1;
|
||||
this.setState({ launchUrl: url, liteMode });
|
||||
liteMode = !isResetUrlSet && url.indexOf('liteMode=1') > -1;
|
||||
this.setState({ launchUrl: resetUrl || url, liteMode });
|
||||
}
|
||||
|
||||
NativeModules.UtilityModule.getNotificationLaunchTarget().then(target => {
|
||||
if (target) {
|
||||
liteMode = target.indexOf('liteMode=1') > -1;
|
||||
this.setState({ launchUrl: target, liteMode });
|
||||
liteMode = !isResetUrlSet && target.indexOf('liteMode=1') > -1;
|
||||
this.setState({ launchUrl: resetUrl || target, liteMode });
|
||||
}
|
||||
|
||||
// Only connect after checking initial launch url / notification launch target
|
||||
|
|
|
@ -4591,9 +4591,9 @@ latest-version@^3.0.0:
|
|||
dependencies:
|
||||
package-json "^4.0.0"
|
||||
|
||||
lbry-redux@lbryio/lbry-redux#f36b91496b3852e3d032b6d360b14d5fafbc07a9:
|
||||
lbry-redux@lbryio/lbry-redux#f6e99498d2bc5b3f07e1e2b6f668a1a48de35047:
|
||||
version "0.0.1"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f36b91496b3852e3d032b6d360b14d5fafbc07a9"
|
||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f6e99498d2bc5b3f07e1e2b6f668a1a48de35047"
|
||||
dependencies:
|
||||
proxy-polyfill "0.1.6"
|
||||
reselect "^3.0.0"
|
||||
|
|
Loading…
Reference in a new issue