back navigation fixes and tweaks

This commit is contained in:
Akinwale Ariwodola 2020-01-24 13:47:41 +01:00
parent 9bc5a2ecac
commit 95a33b411b
6 changed files with 34 additions and 8 deletions

View file

@ -173,7 +173,7 @@ class ChannelPage extends React.PureComponent {
const { permanent_url: permanentUrl } = claim;
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
params: { editChannelUrl: permanentUrl },
params: { editChannelUrl: permanentUrl, returnUrl: permanentUrl },
});
}
};
@ -210,7 +210,7 @@ class ChannelPage extends React.PureComponent {
},
},
],
{ cancelable: true }
{ cancelable: true },
);
}
};

View file

@ -14,7 +14,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import { navigateBack, navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import Button from 'component/button';
import ChannelIconItem from 'component/channelIconItem';
import ChannelRewardsDriver from 'component/channelRewardsDriver';
@ -37,6 +37,7 @@ export default class ChannelCreator extends React.PureComponent {
state = {
autoStyle: null,
returnUrl: null,
canSave: true,
claimId: null,
creditsInputFocused: false,
@ -77,6 +78,7 @@ export default class ChannelCreator extends React.PureComponent {
descriptionFocused: false,
websiteFocused: false,
emailFocused: false,
hasReturnedBack: false,
};
didFocusListener;
@ -118,7 +120,14 @@ export default class ChannelCreator extends React.PureComponent {
};
componentWillReceiveProps(nextProps) {
const { currentRoute: prevRoute, drawerStack: prevDrawerStack, notify } = this.props;
const {
currentRoute: prevRoute,
drawerStack: prevDrawerStack,
popDrawerStack,
setPlayerVisible,
navigation,
notify,
} = this.props;
const { currentRoute, drawerStack, updatingChannel, updateChannelError } = nextProps;
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR === currentRoute && currentRoute !== prevRoute) {
@ -142,6 +151,11 @@ export default class ChannelCreator extends React.PureComponent {
) {
// navigated back from the form
this.setState({ currentPhase: Constants.PHASE_LIST });
if (!this.state.hasReturnedBack && this.state.returnUrl) {
this.setState({ hasReturnedBack: true }, () =>
navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible),
);
}
}
}
@ -171,11 +185,12 @@ export default class ChannelCreator extends React.PureComponent {
let isEditMode = false;
if (navigation.state.params) {
const { editChannelUrl, displayForm } = navigation.state.params;
const { editChannelUrl, displayForm, returnUrl } = navigation.state.params;
if (editChannelUrl) {
isEditMode = true;
this.setState({ editChannelUrl, currentPhase: Constants.PHASE_CREATE });
}
this.setState({ returnUrl });
}
if (!isEditMode && hasFormState) {

View file

@ -86,8 +86,10 @@ class DiscoverPage extends React.PureComponent {
}
onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible } = this.props;
// pushDrawerStack();
const { pushDrawerStack, setPlayerVisible, currentRoute } = this.props;
if (currentRoute === Constants.DRAWER_ROUTE_DISCOVER) {
pushDrawerStack();
}
NativeModules.Firebase.setCurrentScreen('Your tags');
setPlayerVisible();

View file

@ -328,7 +328,11 @@ class FilePage extends React.PureComponent {
onEditPressed = () => {
const { claim, navigation } = this.props;
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
const uri = this.state.uri || this.getPurchaseUrl();
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_PUBLISH,
params: { editMode: true, claimToEdit: claim, returnUrl: uri },
});
};
onDeletePressed = () => {

View file

@ -42,6 +42,9 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
if (lastRoute === Constants.DRAWER_ROUTE_PUBLISH_FORM && routeName === Constants.DRAWER_ROUTE_PUBLISH) {
canPushStack = false;
}
if (routeName === Constants.DRAWER_ROUTE_DISCOVER && newStack.length === 1) {
canPushStack = false;
}
let lastRouteInStack;
if (canPushStack) {

View file

@ -169,6 +169,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
if (popDrawerStack) {
popDrawerStack();
}
if (setPlayerVisible) {
setPlayerVisible(false);
}
@ -176,6 +177,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route, params } = target;
navigation.goBack(navigation.state.key);
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route, null, true, null, setPlayerVisible);
} else {