handle additional params for notifiication cold start

This commit is contained in:
Akinwale Ariwodola 2020-03-09 13:51:53 +01:00
parent 7294848802
commit 40e2080c52
7 changed files with 122 additions and 97 deletions

View file

@ -15,7 +15,7 @@
"base-64": "^0.1.0", "base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0", "@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3", "gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#9c48cce570ee8e057068c86cb6507e1b441841ee", "lbry-redux": "lbryio/lbry-redux#f36b91496b3852e3d032b6d360b14d5fafbc07a9",
"lbryinc": "lbryio/lbryinc#1fc104c2d29d1d3975234c3606e848eaa28e1b6e", "lbryinc": "lbryio/lbryinc#1fc104c2d29d1d3975234c3606e848eaa28e1b6e",
"lodash": ">=4.17.11", "lodash": ">=4.17.11",
"merge": ">=1.2.1", "merge": ">=1.2.1",

View file

@ -93,6 +93,7 @@ const Constants = {
DRAWER_ROUTE_CHANNEL_CREATOR: 'ChannelCreator', DRAWER_ROUTE_CHANNEL_CREATOR: 'ChannelCreator',
DRAWER_ROUTE_CHANNEL_CREATOR_FORM: 'ChannnelCreatorForm', DRAWER_ROUTE_CHANNEL_CREATOR_FORM: 'ChannnelCreatorForm',
DRAWER_ROUTE_INVITES: 'Invites', DRAWER_ROUTE_INVITES: 'Invites',
DRAWER_ROUTE_LITE_FILE: 'LiteFile',
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack', FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
FULL_ROUTE_NAME_WALLET: 'WalletStack', FULL_ROUTE_NAME_WALLET: 'WalletStack',

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Lbry, formatCredits, normalizeURI, parseURI } from 'lbry-redux'; import { Lbry, formatCredits, normalizeURI, parseURI, parseQueryParams } from 'lbry-redux';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { import {
ActivityIndicator, ActivityIndicator,
@ -24,11 +24,10 @@ import Link from 'component/link';
import MediaPlayer from 'component/mediaPlayer'; import MediaPlayer from 'component/mediaPlayer';
import RelatedContent from 'component/relatedContent'; import RelatedContent from 'component/relatedContent';
import filePageStyle from 'styles/filePage'; import filePageStyle from 'styles/filePage';
import { formatLbryUrlForWeb, navigateToUri } from 'utils/helper'; import { decode, formatLbryUrlForWeb, navigateToUri } from 'utils/helper';
import uriBarStyle from 'styles/uriBar';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
import ProgressCircle from 'react-native-progress-circle'; import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from "constants"; import uriBarStyle from 'styles/uriBar';
// This page will only be used for playing audio / video content from a remote stream URL // This page will only be used for playing audio / video content from a remote stream URL
class LiteFilePage extends React.PureComponent { class LiteFilePage extends React.PureComponent {
@ -39,6 +38,9 @@ class LiteFilePage extends React.PureComponent {
player = null; player = null;
state = { state = {
channelName: null,
channelUrl: null,
contentTitle: null,
fullscreenMode: false, fullscreenMode: false,
playerHeight: null, playerHeight: null,
isLandscape: false, isLandscape: false,
@ -102,15 +104,33 @@ class LiteFilePage extends React.PureComponent {
NativeModules.UtilityModule.shareUrl(shareUrl); NativeModules.UtilityModule.shareUrl(shareUrl);
}; };
render() { componentDidUpdate() {
const { navigation, rewardedContentClaimIds, title } = this.props; const { navigation } = this.props;
const { viewCount } = this.state;
const { uri } = navigation.state.params; const { uri } = navigation.state.params;
if (!this.state.contentTitle) {
const params = parseQueryParams(uri);
const { channelUrl, contentTitle } = params;
const channelName = channelUrl ? parseURI(decode(channelUrl)).claimName : null;
this.setState({
title: decode(contentTitle),
channelUrl,
channelName,
showRecommended: true,
});
}
}
render() {
const { navigation, rewardedContentClaimIds } = this.props;
const { channelName, channelUrl, title, viewCount } = this.state;
const { uri } = navigation.state.params;
const { claimName, claimId } = parseURI(uri); const { claimName, claimId } = parseURI(uri);
const isRewardContent = rewardedContentClaimIds.includes(claimId); const isRewardContent = rewardedContentClaimIds.includes(claimId);
const channelName = null;
const channelUri = null; const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
const playerStyle = [ const playerStyle = [
filePageStyle.player, filePageStyle.player,
@ -123,12 +143,27 @@ class LiteFilePage extends React.PureComponent {
return ( return (
<View style={filePageStyle.pageContainer}> <View style={filePageStyle.pageContainer}>
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />} {!this.state.fullscreenMode && <UriBar value={uri.split('?')[0]} navigation={navigation} />}
<View <View
style={this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer} style={this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer}
onLayout={this.checkOrientation} onLayout={this.checkOrientation}
> >
<TouchableOpacity activeOpacity={0.5} style={filePageStyle.mediaContainer} />
<View
style={playerBgStyle}
ref={ref => {
this.playerBackground = ref;
}}
onLayout={evt => {
if (!this.state.playerBgHeight) {
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
}
}}
/>
{this.state.fullscreenMode && <View style={fsPlayerBgStyle} />}
<MediaPlayer <MediaPlayer
assignPlayer={ref => { assignPlayer={ref => {
this.player = ref; this.player = ref;
@ -144,89 +179,74 @@ class LiteFilePage extends React.PureComponent {
} }
}} }}
/> />
</View>
<ScrollView <ScrollView
contentContainerstyle={filePageStyle.scrollContent} style={filePageStyle.scrollContainer}
keyboardShouldPersistTaps={'handled'} contentContainerStyle={filePageStyle.scrollContent}
ref={ref => { keyboardShouldPersistTaps={'handled'}
this.scrollView = ref; ref={ref => {
}} this.scrollView = ref;
> }}
<TouchableWithoutFeedback
style={filePageStyle.titleTouch}
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
> >
<View style={filePageStyle.titleArea}> <TouchableWithoutFeedback
<View style={filePageStyle.titleRow}> style={filePageStyle.titleTouch}
<Text style={filePageStyle.title} selectable> onPress={() => this.setState({ showDescription: !this.state.showDescription })}
{title}
</Text>
{isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
</View>
<Text style={filePageStyle.viewCount}>
{viewCount === 1 && __('%view% view', { view: viewCount })}
{viewCount > 1 && __('%view% views', { view: viewCount })}
</Text>
</View>
</TouchableWithoutFeedback>
<View style={filePageStyle.largeButtonsRow}>
<TouchableOpacity style={filePageStyle.largeButton} onPress={() => this.handleSharePress(uri)}>
<Icon name={'share-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<Text style={filePageStyle.largeButtonText}>{__('Share')}</Text>
</TouchableOpacity>
<TouchableOpacity
style={filePageStyle.largeButton}
onPress={() => this.setState({ showTipView: true })}
> >
<Icon name={'gift'} size={16} style={filePageStyle.largeButtonIcon} /> <View style={filePageStyle.titleArea}>
<Text style={filePageStyle.largeButtonText}>{__('Tip')}</Text> <View style={filePageStyle.titleRow}>
</TouchableOpacity> <Text style={filePageStyle.title} selectable>
</View> {title}
</Text>
<View style={filePageStyle.channelRow}> {isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
<View style={filePageStyle.publishInfo}> </View>
{channelName && ( <Text style={filePageStyle.viewCount}>
<Link {viewCount === 1 && __('%view% view', { view: viewCount })}
style={filePageStyle.channelName} {viewCount > 1 && __('%view% views', { view: viewCount })}
selectable
text={channelName}
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(
navigation,
normalizeURI(channelUri),
null,
false,
null,
false,
);
}}
/>
)}
{!channelName && (
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
{__('Anonymous')}
</Text> </Text>
)} </View>
</TouchableWithoutFeedback>
<View style={filePageStyle.largeButtonsRow}>
<TouchableOpacity style={filePageStyle.largeButton} onPress={() => this.handleSharePress(uri)}>
<Icon name={'share-alt'} size={16} style={filePageStyle.largeButtonIcon} />
<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>
</View> </View>
</View>
<View onLayout={this.setRelatedContentPosition} /> <View style={filePageStyle.channelRow}>
<View style={filePageStyle.publishInfo}>
{channelName && (
<Link
style={filePageStyle.channelName}
selectable
text={channelName}
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(navigation, normalizeURI(channelUrl), null, false, null, false);
}}
/>
)}
{!channelName && (
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
{__('Anonymous')}
</Text>
)}
</View>
</View>
{this.state.showRecommended && ( <View onLayout={this.setRelatedContentPosition} />
<RelatedContent
navigation={navigation} {this.state.showRecommended && (
claimId={claimId} <RelatedContent navigation={navigation} claimId={claimId} title={title} uri={uri} fullUri={uri} />
title={title} )}
uri={uri} </ScrollView>
fullUri={uri} </View>
/>
)}
</ScrollView>
</View> </View>
); );
} }

View file

@ -160,12 +160,13 @@ class SplashScreen extends React.PureComponent {
navigateToLiteMode = () => { navigateToLiteMode = () => {
const { navigation } = this.props; const { navigation } = this.props;
const { launchUrl } = this.state;
const resetAction = StackActions.reset({ const resetAction = StackActions.reset({
index: 0, index: 0,
actions: [ actions: [
NavigationActions.navigate({ NavigationActions.navigate({
routeName: 'LiteFile', routeName: Constants.DRAWER_ROUTE_LITE_FILE,
params: { uri: this.state.launchUrl.replace(/liteMode=1/gi, '') }, params: { uri: launchUrl },
}), }),
], ],
}); });

View file

@ -45,15 +45,14 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
if (routeName === Constants.DRAWER_ROUTE_SUBSCRIPTIONS && newStack.length === 1) { if (routeName === Constants.DRAWER_ROUTE_SUBSCRIPTIONS && newStack.length === 1) {
canPushStack = false; canPushStack = false;
} }
if (routeName === Constants.DRAWER_ROUTE_LITE_FILE) {
canPushStack = false;
}
let lastRouteInStack; let lastRouteInStack;
if (canPushStack) { if (canPushStack) {
newStack.push({ route: routeName, params }); newStack.push({ route: routeName, params });
lastRouteInStack = { route: routeName, params };
// save the route (if it's not lite mode)
if (routeName.toLowerCase() !== 'litefile') {
lastRouteInStack = { route: routeName, params };
}
} }
return { return {

View file

@ -432,3 +432,7 @@ export function fetchReferralCode(successCallback, errorCallback) {
} }
}); });
} }
export function decode(value) {
return decodeURIComponent(value).replace(/\+/g, ' ');
}

View file

@ -4591,9 +4591,9 @@ latest-version@^3.0.0:
dependencies: dependencies:
package-json "^4.0.0" package-json "^4.0.0"
lbry-redux@lbryio/lbry-redux#9c48cce570ee8e057068c86cb6507e1b441841ee: lbry-redux@lbryio/lbry-redux#f36b91496b3852e3d032b6d360b14d5fafbc07a9:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/9c48cce570ee8e057068c86cb6507e1b441841ee" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/f36b91496b3852e3d032b6d360b14d5fafbc07a9"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"