fix ongoing playback when back button pressed

This commit is contained in:
Akinwale Ariwodola 2020-01-14 08:49:34 +01:00
parent f2b0d3417b
commit 8f28aed662
2 changed files with 8 additions and 4 deletions

View file

@ -737,8 +737,8 @@ class FilePage extends React.PureComponent {
}; };
onBackButtonPressed = () => { onBackButtonPressed = () => {
const { navigation, drawerStack, popDrawerStack } = this.props; const { navigation, drawerStack, popDrawerStack, setPlayerVisible } = this.props;
navigateBack(navigation, drawerStack, popDrawerStack); navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible);
}; };
onOpenFilePressed = () => { onOpenFilePressed = () => {

View file

@ -1,7 +1,7 @@
import { NavigationActions, StackActions } from 'react-navigation'; import { NavigationActions, StackActions } from 'react-navigation';
import { buildURI, isURIValid, normalizeURI } from 'lbry-redux'; import { buildURI, isURIValid, normalizeURI } from 'lbry-redux';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { doPopDrawerStack, doPushDrawerStack } from 'redux/actions/drawer'; import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants, { DrawerRoutes, InnerDrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants, { DrawerRoutes, InnerDrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
const tagNameLength = 10; const tagNameLength = 10;
@ -151,7 +151,7 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
} }
} }
export function navigateBack(navigation, drawerStack, popDrawerStack) { export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible) {
if (drawerStack[drawerStack.length - 1].route === Constants.DRAWER_ROUTE_FILE_VIEW) { if (drawerStack[drawerStack.length - 1].route === Constants.DRAWER_ROUTE_FILE_VIEW) {
// inner file_view (web / image view) is handled differently // inner file_view (web / image view) is handled differently
if (popDrawerStack) { if (popDrawerStack) {
@ -163,6 +163,9 @@ export function navigateBack(navigation, drawerStack, popDrawerStack) {
if (popDrawerStack) { if (popDrawerStack) {
popDrawerStack(); popDrawerStack();
} }
if (setPlayerVisible) {
setPlayerVisible(false);
}
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0]; const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route, params } = target; const { route, params } = target;
@ -198,6 +201,7 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
} }
dispatch(doPopDrawerStack()); dispatch(doPopDrawerStack());
dispatch(doSetPlayerVisible(false));
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0]; const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route } = target; const { route } = target;