Commit 456c7876 authored by Akinwale Ariwodola's avatar Akinwale Ariwodola
Browse files

fix channel creator and publish back navigation to corresponding claims.

parent 95a33b41
......@@ -64,6 +64,8 @@ const Constants = {
ACTION_CLEAR_PUBLISH_FORM_STATE: 'CLEAR_PUBLISH_FORM_STATE',
ACTION_CLEAR_CHANNEL_FORM_STATE: 'CLEAR_CHANNEL_FORM_STATE',
ACTION_SET_EXPLICIT_NAVIGATE_BACK: 'SET_EXPLICIT_NAVIGATE_BACK',
ACTION_FULLSCREEN_MODE_TOGGLED: 'FULLSCREEN_MODE_TOGGLED',
ORIENTATION_HORIZONTAL: 'horizontal',
......
......@@ -176,6 +176,7 @@ class ChannelPage extends React.PureComponent {
params: { editChannelUrl: permanentUrl, returnUrl: permanentUrl },
});
}
this.onEditPressed = null;
};
onTipPressed = () => {
......
......@@ -13,7 +13,12 @@ import {
doToast,
} from 'lbry-redux';
import { doGetSync } from 'lbryinc';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import {
doPushDrawerStack,
doPopDrawerStack,
doSetPlayerVisible,
doSetExplicitNavigateBack,
} from 'redux/actions/drawer';
import { doUpdateChannelFormState, doClearChannelFormState } from 'redux/actions/form';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { selectChannelFormState, selectHasChannelFormState } from 'redux/selectors/form';
......@@ -44,9 +49,10 @@ const perform = dispatch => ({
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
setExplicitNavigateBack: flag => dispatch(doSetExplicitNavigateBack(flag)),
});
export default connect(
select,
perform
perform,
)(ChannelCreator);
......@@ -152,9 +152,9 @@ 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),
);
this.setState({ hasReturnedBack: true }, () => {
navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible);
});
}
}
}
......
......@@ -47,7 +47,7 @@ import Tag from 'component/tag';
import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
import { navigateToUri, navigateBack, logPublish, uploadImageAsset } from 'utils/helper';
const languages = {
en: 'English',
......@@ -141,6 +141,8 @@ class PublishPage extends React.PureComponent {
// other
publishStarted: false,
storagePermissionRequired: false,
hasReturnedBack: false,
returnUrl: null,
};
didFocusListener;
......@@ -236,7 +238,7 @@ class PublishPage extends React.PureComponent {
let isEditMode = false,
vanityUrlSet = false;
if (navigation.state.params) {
const { displayForm, editMode, claimToEdit, vanityUrl } = navigation.state.params;
const { displayForm, editMode, claimToEdit, vanityUrl, returnUrl } = navigation.state.params;
if (editMode) {
this.prepareEdit(claimToEdit);
isEditMode = true;
......@@ -250,6 +252,7 @@ class PublishPage extends React.PureComponent {
vanityUrl: claimName,
});
}
this.setState({ returnUrl });
}
if (!isEditMode && hasFormState) {
......@@ -472,7 +475,15 @@ class PublishPage extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
const { currentRoute: prevRoute, drawerStack: prevDrawerStack, notify, updatePublishFormState } = this.props;
const {
currentRoute: prevRoute,
drawerStack: prevDrawerStack,
popDrawerStack,
setPlayerVisible,
navigation,
notify,
updatePublishFormState,
} = this.props;
const { currentRoute, drawerStack, publishFormValues } = nextProps;
if (Constants.DRAWER_ROUTE_PUBLISH === currentRoute && currentRoute !== prevRoute) {
......@@ -486,6 +497,11 @@ class PublishPage extends React.PureComponent {
) {
// navigated back from the form
this.showSelector();
if (!this.state.hasReturnedBack && this.state.returnUrl) {
this.setState({ hasReturnedBack: true }, () => {
navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible);
});
}
}
}
......
......@@ -187,7 +187,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_CHANNEL_CREATOR;
} else if (Constants.DRAWER_ROUTE_PUBLISH_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_PUBLISH_FORM;
targetRoute = Constants.DRAWER_ROUTE_PUBLISH;
}
if (targetParams) {
......@@ -202,8 +202,15 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
}
export function dispatchNavigateBack(dispatch, nav, drawerStack) {
if (drawerStack[drawerStack.length - 1].route === Constants.DRAWER_ROUTE_FILE_VIEW) {
// inner file_view (web / image view) is handled differently
const currentRoute = drawerStack[drawerStack.length - 1].route;
if (
[
Constants.DRAWER_ROUTE_FILE_VIEW,
Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM,
Constants.DRAWER_ROUTE_PUBLISH_FORM,
].includes(currentRoute)
) {
// inner routes are handled a little differently
dispatch(doPopDrawerStack());
return;
}
......@@ -224,7 +231,7 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_CHANNEL_CREATOR;
} else if (Constants.DRAWER_ROUTE_PUBLISH_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_PUBLISH_FORM;
targetRoute = Constants.DRAWER_ROUTE_PUBLISH;
}
if (targetParams) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment