Commit 3717a807 authored by Akinwale Ariwodola's avatar Akinwale Ariwodola
Browse files

error on publish to existing content address

parent 46bfbd24
import { connect } from 'react-redux';
import {
doPublish,
doFetchClaimListMine,
doResolveUri,
doToast,
doUpdatePublishForm,
......@@ -27,6 +28,7 @@ const select = state => ({
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
clearPublishFormState: () => dispatch(doClearPublishFormState()),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
pendingPublishSuccess: pendingClaim => dispatch(doPendingPublishSuccess(pendingClaim)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
......@@ -39,5 +41,5 @@ const perform = dispatch => ({
export default connect(
select,
perform
perform,
)(PublishPage);
......@@ -209,7 +209,7 @@ class PublishPage extends React.PureComponent {
};
onComponentFocused = () => {
const { balance, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
const { balance, fetchMyClaims, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
setPlayerVisible();
......@@ -219,6 +219,7 @@ class PublishPage extends React.PureComponent {
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
fetchMyClaims();
NativeModules.UtilityModule.canReadWriteStorage().then(canReadWrite => {
if (!canReadWrite) {
......@@ -356,7 +357,7 @@ class PublishPage extends React.PureComponent {
};
handlePublishPressed = () => {
const { balance, notify, publish, updatePublishForm } = this.props;
const { balance, myClaims, notify, publish, updatePublishForm } = this.props;
const {
editMode,
bid,
......@@ -400,6 +401,14 @@ class PublishPage extends React.PureComponent {
if (!isNameValid(name, false)) {
notify({ message: __('Your content address contains invalid characters.'), isError: true });
return;
} else if (myClaims && myClaims.length > 0) {
if (myClaims.some(claim => claim.name.toLowerCase() === name.trim().toLowerCase())) {
notify({
message: __('You have already published to the specified content address. Please enter a new address.'),
isError: true,
});
return;
}
}
if (!currentMedia && !editMode) {
......@@ -628,7 +637,7 @@ class PublishPage extends React.PureComponent {
}
} else {
// could not determine the file path
notify({ message: __('The path could not be determined. Please try a different file.') });
notify({ message: __('The path could not be determined. Please try a different file.'), isError: true });
}
};
......
......@@ -59,10 +59,12 @@ class SplashScreen extends React.PureComponent {
} else if (lastRouteInStack) {
// no launch url, check if there's a last route in stack to navigate to.
const { route, params } = lastRouteInStack;
if (!DrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route);
} else {
navigation.navigate({ routeName: route, params });
if (route) {
if (!DrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route);
} else {
navigation.navigate({ routeName: route, params });
}
}
}
};
......
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