fix double-playback when navigating to related content links
This commit is contained in:
parent
8f28aed662
commit
fefc13bc7a
11 changed files with 35 additions and 15 deletions
|
@ -10,6 +10,7 @@ import {
|
||||||
makeSelectTitleForUri,
|
makeSelectTitleForUri,
|
||||||
makeSelectThumbnailForUri,
|
makeSelectThumbnailForUri,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
||||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import ClaimResultItem from './view';
|
import ClaimResultItem from './view';
|
||||||
|
@ -32,6 +33,7 @@ const select = (state, props) => ({
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||||
|
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -39,14 +39,14 @@ class ClaimResultItem extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
onPressHandler = () => {
|
onPressHandler = () => {
|
||||||
const { autoplay, navigation, result } = this.props;
|
const { autoplay, navigation, result, setPlayerVisible } = this.props;
|
||||||
const { claimId, name } = result;
|
const { claimId, name } = result;
|
||||||
const url = normalizeURI(`${name}#${claimId}`);
|
const url = normalizeURI(`${name}#${claimId}`);
|
||||||
navigateToUri(navigation, url, { autoplay }, false, url);
|
navigateToUri(navigation, url, { autoplay }, false, url, setPlayerVisible);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fileInfo, navigation, obscureNsfw, result, rewardedContentClaimIds, style } = this.props;
|
const { fileInfo, navigation, obscureNsfw, result, rewardedContentClaimIds, setPlayerVisible, style } = this.props;
|
||||||
const {
|
const {
|
||||||
channel,
|
channel,
|
||||||
channel_claim_id: channelClaimId,
|
channel_claim_id: channelClaimId,
|
||||||
|
@ -134,6 +134,7 @@ class ClaimResultItem extends React.PureComponent {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
isChannel ? url : channelUrl,
|
isChannel ? url : channelUrl,
|
||||||
|
setPlayerVisible,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
makeSelectShortUrlForUri,
|
makeSelectShortUrlForUri,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
||||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import FileItem from './view';
|
import FileItem from './view';
|
||||||
|
@ -31,9 +32,10 @@ const select = (state, props) => ({
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||||
|
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
select,
|
select,
|
||||||
perform
|
perform,
|
||||||
)(FileItem);
|
)(FileItem);
|
||||||
|
|
|
@ -56,6 +56,7 @@ class FileItem extends React.PureComponent {
|
||||||
obscureNsfw,
|
obscureNsfw,
|
||||||
showDetails,
|
showDetails,
|
||||||
compactView,
|
compactView,
|
||||||
|
setPlayerVisible,
|
||||||
titleBeforeThumbnail,
|
titleBeforeThumbnail,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -135,6 +136,7 @@ class FileItem extends React.PureComponent {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
fullChannelUri,
|
fullChannelUri,
|
||||||
|
setPlayerVisible,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
makeSelectTitleForUri,
|
makeSelectTitleForUri,
|
||||||
makeSelectThumbnailForUri,
|
makeSelectThumbnailForUri,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
|
||||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||||
import FileListItem from './view';
|
import FileListItem from './view';
|
||||||
|
@ -32,6 +33,7 @@ const select = (state, props) => ({
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||||
|
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -80,6 +80,7 @@ class FileListItem extends React.PureComponent {
|
||||||
onPress,
|
onPress,
|
||||||
navigation,
|
navigation,
|
||||||
rewardedContentClaimIds,
|
rewardedContentClaimIds,
|
||||||
|
setPlayerVisible,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
hideChannel,
|
hideChannel,
|
||||||
onLongPress,
|
onLongPress,
|
||||||
|
@ -236,6 +237,7 @@ class FileListItem extends React.PureComponent {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
isChannel ? claim && claim.permanent_url : fullChannelUri,
|
isChannel ? claim && claim.permanent_url : fullChannelUri,
|
||||||
|
setPlayerVisible,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
selectSearchSuggestions,
|
selectSearchSuggestions,
|
||||||
SETTINGS,
|
SETTINGS,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import UriBar from './view';
|
import UriBar from './view';
|
||||||
|
@ -24,9 +25,10 @@ const select = state => {
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
|
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
|
||||||
|
setPlayerVisible: (visible, uri) => dispatch(doSetPlayerVisible(visible, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
select,
|
select,
|
||||||
perform
|
perform,
|
||||||
)(UriBar);
|
)(UriBar);
|
||||||
|
|
|
@ -83,7 +83,7 @@ class UriBar extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleItemPress = item => {
|
handleItemPress = item => {
|
||||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
const { navigation, onSearchSubmitted, setPlayerVisible, updateSearchQuery } = this.props;
|
||||||
const { type, value } = item;
|
const { type, value } = item;
|
||||||
|
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
|
@ -112,7 +112,7 @@ class UriBar extends React.PureComponent {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const uri = normalizeURI(value);
|
const uri = normalizeURI(value);
|
||||||
navigateToUri(navigation, uri);
|
navigateToUri(navigation, uri, null, false, null, setPlayerVisible);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class UriBar extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSubmitEditing = () => {
|
handleSubmitEditing = () => {
|
||||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
const { navigation, onSearchSubmitted, setPlayerVisible, updateSearchQuery } = this.props;
|
||||||
if (this.state.inputText) {
|
if (this.state.inputText) {
|
||||||
let inputText = this.state.inputText,
|
let inputText = this.state.inputText,
|
||||||
inputTextIsUrl = false;
|
inputTextIsUrl = false;
|
||||||
|
@ -137,7 +137,7 @@ class UriBar extends React.PureComponent {
|
||||||
// if it's a URI (lbry://...), open the file page
|
// if it's a URI (lbry://...), open the file page
|
||||||
if (transformedUrl && isURIValid(transformedUrl)) {
|
if (transformedUrl && isURIValid(transformedUrl)) {
|
||||||
inputTextIsUrl = true;
|
inputTextIsUrl = true;
|
||||||
navigateToUri(navigation, transformedUrl);
|
navigateToUri(navigation, transformedUrl, null, false, null, setPlayerVisible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class DownloadsPage extends React.PureComponent {
|
||||||
const { claims, fileInfos } = this.props;
|
const { claims, fileInfos } = this.props;
|
||||||
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
|
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
|
||||||
return fileInfos.filter(
|
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,
|
cancelable: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ class DownloadsPage extends React.PureComponent {
|
||||||
this.handleSelectItem(item, claim);
|
this.handleSelectItem(item, claim);
|
||||||
} else {
|
} else {
|
||||||
// TODO: when shortUrl is available for my claims, navigate to that URL instead
|
// 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)}
|
onLongPress={claim => this.handleItemLongPress(item, claim)}
|
||||||
|
|
|
@ -117,7 +117,6 @@ class FilePage extends React.PureComponent {
|
||||||
StatusBar.setHidden(false);
|
StatusBar.setHidden(false);
|
||||||
NativeModules.Firebase.setCurrentScreen('File').then(result => {
|
NativeModules.Firebase.setCurrentScreen('File').then(result => {
|
||||||
const { setPlayerVisible } = this.props;
|
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('onStoragePermissionGranted', this.handleStoragePermissionGranted);
|
||||||
DeviceEventEmitter.addListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
|
DeviceEventEmitter.addListener('onStoragePermissionRefused', this.handleStoragePermissionRefused);
|
||||||
|
@ -885,6 +884,7 @@ class FilePage extends React.PureComponent {
|
||||||
position,
|
position,
|
||||||
purchaseUri,
|
purchaseUri,
|
||||||
pushDrawerStack,
|
pushDrawerStack,
|
||||||
|
setPlayerVisible,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
title,
|
title,
|
||||||
viewCount,
|
viewCount,
|
||||||
|
@ -1274,6 +1274,7 @@ class FilePage extends React.PureComponent {
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
fullChannelUri,
|
fullChannelUri,
|
||||||
|
setPlayerVisible,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -56,6 +56,8 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack, full
|
||||||
dispatch(doPushDrawerStack(uri));
|
dispatch(doPushDrawerStack(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch(doSetPlayerVisible(false));
|
||||||
|
|
||||||
if (nav && nav.routes && nav.routes.length > 0 && nav.routes[0].routeName === 'Main') {
|
if (nav && nav.routes && nav.routes.length > 0 && nav.routes[0].routeName === 'Main') {
|
||||||
const mainRoute = nav.routes[0];
|
const mainRoute = nav.routes[0];
|
||||||
const discoverRoute = mainRoute.routes[0];
|
const discoverRoute = mainRoute.routes[0];
|
||||||
|
@ -112,7 +114,7 @@ function parseUriVars(vars) {
|
||||||
return uriVars;
|
return uriVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri) {
|
export function navigateToUri(navigation, uri, additionalParams, isNavigatingBack, fullUri, setPlayerVisible) {
|
||||||
if (!navigation) {
|
if (!navigation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,10 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
|
||||||
uriVars = parseUriVars(uriVarsStr);
|
uriVars = parseUriVars(uriVarsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setPlayerVisible) {
|
||||||
|
setPlayerVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
const { store } = window;
|
const { store } = window;
|
||||||
const params = Object.assign({ uri, uriVars, fullUri: fullUri }, additionalParams);
|
const params = Object.assign({ uri, uriVars, fullUri: fullUri }, additionalParams);
|
||||||
if (navigation.state.routeName === 'File') {
|
if (navigation.state.routeName === 'File') {
|
||||||
|
@ -171,7 +177,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
|
||||||
const { route, params } = target;
|
const { route, params } = target;
|
||||||
navigation.goBack(navigation.state.key);
|
navigation.goBack(navigation.state.key);
|
||||||
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
|
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
|
||||||
navigateToUri(navigation, route, null, true);
|
navigateToUri(navigation, route, null, true, null, setPlayerVisible);
|
||||||
} else {
|
} else {
|
||||||
let targetRoute = route;
|
let targetRoute = route;
|
||||||
let targetParams = params;
|
let targetParams = params;
|
||||||
|
|
Loading…
Reference in a new issue