Playable downloads #111

Merged
akinwale merged 7 commits from playable-downloads into master 2020-01-16 22:00:34 +01:00
11 changed files with 35 additions and 15 deletions
Showing only changes of commit fefc13bc7a - Show all commits

View file

@ -10,6 +10,7 @@ import {
makeSelectTitleForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux';
import { doSetPlayerVisible } from 'redux/actions/drawer';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import ClaimResultItem from './view';
@ -32,6 +33,7 @@ const select = (state, props) => ({
const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)),
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
});
export default connect(

View file

@ -39,14 +39,14 @@ class ClaimResultItem extends React.PureComponent {
}
onPressHandler = () => {
const { autoplay, navigation, result } = this.props;
const { autoplay, navigation, result, setPlayerVisible } = this.props;
const { claimId, name } = result;
const url = normalizeURI(`${name}#${claimId}`);
navigateToUri(navigation, url, { autoplay }, false, url);
navigateToUri(navigation, url, { autoplay }, false, url, setPlayerVisible);
};
render() {
const { fileInfo, navigation, obscureNsfw, result, rewardedContentClaimIds, style } = this.props;
const { fileInfo, navigation, obscureNsfw, result, rewardedContentClaimIds, setPlayerVisible, style } = this.props;
const {
channel,
channel_claim_id: channelClaimId,
@ -134,6 +134,7 @@ class ClaimResultItem extends React.PureComponent {
null,
false,
isChannel ? url : channelUrl,
setPlayerVisible,
);
}}
/>

View file

@ -10,6 +10,7 @@ import {
makeSelectClaimIsNsfw,
makeSelectShortUrlForUri,
} from 'lbry-redux';
import { doSetPlayerVisible } from 'redux/actions/drawer';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import FileItem from './view';
@ -31,9 +32,10 @@ const select = (state, props) => ({
const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)),
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
});
export default connect(
select,
perform
perform,
)(FileItem);

View file

@ -56,6 +56,7 @@ class FileItem extends React.PureComponent {
obscureNsfw,
showDetails,
compactView,
setPlayerVisible,
titleBeforeThumbnail,
} = this.props;
@ -135,6 +136,7 @@ class FileItem extends React.PureComponent {
null,
false,
fullChannelUri,
setPlayerVisible,
);
}}
/>

View file

@ -10,6 +10,7 @@ import {
makeSelectTitleForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux';
import { doSetPlayerVisible } from 'redux/actions/drawer';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import FileListItem from './view';
@ -32,6 +33,7 @@ const select = (state, props) => ({
const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri)),
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
});
export default connect(

View file

@ -80,6 +80,7 @@ class FileListItem extends React.PureComponent {
onPress,
navigation,
rewardedContentClaimIds,
setPlayerVisible,
thumbnail,
hideChannel,
onLongPress,
@ -236,6 +237,7 @@ class FileListItem extends React.PureComponent {
null,
false,
isChannel ? claim && claim.permanent_url : fullChannelUri,
setPlayerVisible,
);
}}
/>

View file

@ -6,6 +6,7 @@ import {
selectSearchSuggestions,
SETTINGS,
} from 'lbry-redux';
import { doSetPlayerVisible } from 'redux/actions/drawer';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import UriBar from './view';
@ -24,9 +25,10 @@ const select = state => {
const perform = dispatch => ({
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
});
export default connect(
select,
perform
perform,
)(UriBar);

View file

@ -83,7 +83,7 @@ class UriBar extends React.PureComponent {
};
handleItemPress = item => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
const { navigation, onSearchSubmitted, setPlayerVisible, updateSearchQuery } = this.props;
const { type, value } = item;
Keyboard.dismiss();
@ -112,7 +112,7 @@ class UriBar extends React.PureComponent {
});
} else {
const uri = normalizeURI(value);
navigateToUri(navigation, uri);
navigateToUri(navigation, uri, null, false, null, setPlayerVisible);
}
};
@ -128,7 +128,7 @@ class UriBar extends React.PureComponent {
};
handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
const { navigation, onSearchSubmitted, setPlayerVisible, updateSearchQuery } = this.props;
if (this.state.inputText) {
let inputText = this.state.inputText,
inputTextIsUrl = false;
@ -137,7 +137,7 @@ class UriBar extends React.PureComponent {
// if it's a URI (lbry://...), open the file page
if (transformedUrl && isURIValid(transformedUrl)) {
inputTextIsUrl = true;
navigateToUri(navigation, transformedUrl);
navigateToUri(navigation, transformedUrl, null, false, null, setPlayerVisible);
}
}

View file

@ -79,7 +79,7 @@ class DownloadsPage extends React.PureComponent {
const { claims, fileInfos } = this.props;
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
return fileInfos.filter(
fileInfo => !claimUris.includes(normalizeURI(`${fileInfo.claim_name}#${fileInfo.claim_id}`))
fileInfo => !claimUris.includes(normalizeURI(`${fileInfo.claim_name}#${fileInfo.claim_id}`)),
);
};
@ -135,7 +135,7 @@ class DownloadsPage extends React.PureComponent {
],
{
cancelable: true,
}
},
);
};
@ -184,7 +184,7 @@ class DownloadsPage extends React.PureComponent {
this.handleSelectItem(item, claim);
} else {
// TODO: when shortUrl is available for my claims, navigate to that URL instead
navigateToUri(navigation, item, { autoplay: true });
navigateToUri(navigation, item, { autoplay: true }, false, null);
}
}}
onLongPress={claim => this.handleItemLongPress(item, claim)}

View file

@ -117,7 +117,6 @@ class FilePage extends React.PureComponent {
StatusBar.setHidden(false);
NativeModules.Firebase.setCurrentScreen('File').then(result => {
const { setPlayerVisible } = this.props;
setPlayerVisible(false); // reset visible state for all other file pages that may be active
DeviceEventEmitter.addListener('onStoragePermissionGranted', this.handleStoragePermissionGranted);
DeviceEventEmitter.addListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
@ -885,6 +884,7 @@ class FilePage extends React.PureComponent {
position,
purchaseUri,
pushDrawerStack,
setPlayerVisible,
thumbnail,
title,
viewCount,
@ -1274,6 +1274,7 @@ class FilePage extends React.PureComponent {
null,
false,
fullChannelUri,
setPlayerVisible,
);
}}
/>

View file

@ -56,6 +56,8 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack, full
dispatch(doPushDrawerStack(uri));
}
dispatch(doSetPlayerVisible(false));
if (nav && nav.routes && nav.routes.length > 0 && nav.routes[0].routeName === 'Main') {
const mainRoute = nav.routes[0];
const discoverRoute = mainRoute.routes[0];
@ -112,7 +114,7 @@ function parseUriVars(vars) {
return uriVars;
}
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri) {
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri, setPlayerVisible) {
if (!navigation) {
return;
}
@ -134,6 +136,10 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
uriVars = parseUriVars(uriVarsStr);
}
if (setPlayerVisible) {
setPlayerVisible(false);
}
const { store } = window;
const params = Object.assign({ uri, uriVars, fullUri: fullUri }, additionalParams);
if (navigation.state.routeName === 'File') {
@ -171,7 +177,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
const { route, params } = target;
navigation.goBack(navigation.state.key);
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route, null, true);
navigateToUri(navigation, route, null, true, null, setPlayerVisible);
} else {
let targetRoute = route;
let targetParams = params;