Commit fdecd309 authored by / /\ / /\/'s avatar / /\ / /\/
Browse files

Revert "wip, add error handling for improper community account create creds"

This reverts commit 969e8cfd.
parent 197b1361
......@@ -21,8 +21,6 @@ const CreateCommunity = ({
updateCommunityNSFW,
updateCommunityOwnerAccountName,
updateCommunityOwnerWifPassword,
communityHivemindOperationPending,
communityHivemindOperationError,
}) => {
const handleCommunityTitleInput = e => {
if (e.target.value.length > 32) {
......@@ -88,12 +86,12 @@ const CreateCommunity = ({
const rememberCredentialsPrompt = (
<div>
<div>{`${tt(
'g.community_owner_name_is'
)}: ${communityOwnerName}`}</div>
<div>{`${tt(
'g.community_password_is'
)}: ${communityOwnerWifPassword}`}</div>
<div>{`${tt('g.community_owner_name_is')}: ${
communityOwnerName
}`}</div>
<div>{`${tt('g.community_password_is')}: ${
communityOwnerWifPassword
}`}</div>
</div>
);
......@@ -125,18 +123,9 @@ const CreateCommunity = ({
</a>
</div>
);
const createCommunityErrorMessage = <div>{tt('g.community_error')}</div>;
const createCommunityLoadingMessage = (
<div>{tt('g.community_creating')}</div>
);
const createCommunityCustomOpsPendingMessage = (
<div>{`${tt('g.community_broadcasting_custom_ops')} ${accountName} ${tt(
'community_broadcasting_custom_ops_1'
)} ${communityTitle}} ${tt(
'community_broadcasting_custom_ops_2'
)}`}</div>
);
const createCommunityLoading = <div>{tt('g.community_creating')}</div>;
const createCommunityForm = (
<form onSubmit={handleCommunitySubmit}>
......@@ -193,9 +182,7 @@ const CreateCommunity = ({
{!communityCreatePending &&
!communityCreateSuccess &&
createCommunityForm}
{communityCreatePending && createCommunityLoadingMessage}
{communityHivemindOperationPending &&
createCommunityCustomOpsPendingMessage}
{communityCreatePending && createCommunityLoading}
{communityCreateSuccess && createCommunitySuccessMessage}
{communityCreateError && createCommunityErrorMessage}
</div>
......@@ -247,13 +234,8 @@ export default connect(
createCommunityPayload
)
);
const errorCallback = () =>
dispatch(
communityActions.createCommunityAccountError(true)
);
const payload = {
successCallback: successCallback,
errorCallback: errorCallback,
...createCommunityPayload,
};
dispatch(communityActions.createCommunity(payload));
......
......@@ -25,9 +25,6 @@
"community_owner_name_is": "Your community owner name is",
"community_password_is": "Your password is",
"community_creating": "Your community is being created...",
"community_broadcasting_custom_ops": "Making",
"community_broadcasting_custom_ops_1": "administrator of the",
"community_broadcasting_custom_ops_2": "community.",
"community_visit": "Visit your community",
"community_error":
"Oops, there was an error creating the community, please try again.",
......
......@@ -15,13 +15,13 @@ export const CREATE_COMMUNITY_ACCOUNT_PENDING =
'community/CREATE_COMMUNITY_ACCOUNT_PENDING';
export const CREATE_COMMUNITY_ACCOUNT_ERROR =
'community/CREATE_COMMUNITY_ACCOUNT_ERROR';
export const CREATE_COMMUNITY_ERROR = 'community/CREATE_COMMUNITY_ERROR';
export const CREATE_COMMUNITY_SUCCESS = 'community/CREATE_COMMUNITY_SUCCESS';
export const COMMUNITY_HIVEMIND_OPERATION =
'community/COMMUNITY_HIVEMIND_OPERATION'; // Has saga.
export const COMMUNITY_HIVEMIND_OPERATION_PENDING =
const COMMUNITY_HIVEMIND_OPERATION_PENDING =
'community/COMMUNITY_HIVEMIND_OPERATION_PENDING';
export const COMMUNITY_HIVEMIND_OPERATION_ERROR =
const COMMUNITY_HIVEMIND_OPERATION_ERROR =
'community/COMMUNITY_HIVEMIND_OPERATION_ERROR';
// Saga-related
......@@ -65,15 +65,12 @@ export default function reducer(state = defaultState, action) {
case CREATE_COMMUNITY_ACCOUNT: {
return state;
}
// Has a saga watcher.
case CREATE_COMMUNITY_ACCOUNT_ERROR: {
return state;
}
case CREATE_COMMUNITY_ACCOUNT_PENDING: {
const pending = fromJS(payload);
return state.merge({ communityCreatePending: pending });
}
case CREATE_COMMUNITY_ERROR: {
case CREATE_COMMUNITY_ACCOUNT_ERROR: {
const err = fromJS(payload);
return state.merge({ communityCreateError: err });
}
......@@ -135,12 +132,10 @@ export const createCommunityAccountPending = payload => ({
type: CREATE_COMMUNITY_ACCOUNT_PENDING,
payload,
});
export const createCommunityAccountError = payload => ({
type: CREATE_COMMUNITY_ACCOUNT_ERROR,
payload,
});
export const createCommunitySuccess = payload => ({
type: CREATE_COMMUNITY_SUCCESS,
payload,
......
......@@ -5,6 +5,10 @@ import * as communityActions from './CommunityReducer';
import * as transactionActions from './TransactionReducer';
import { wait } from './MarketSaga';
const activeKeySelector = state => {
return state.user.getIn(['pub_keys_used']).active;
};
const generateAuth = (user, pass, type) => {
const key = auth.getPrivateKeys(user, pass, [type]);
const publicKey = auth.wifToPublic(Object.values(key)[0]);
......@@ -34,22 +38,7 @@ export const communityWatches = [
createCommunityAccount
),
takeLatest(communityActions.COMMUNITY_HIVEMIND_OPERATION, customOps),
takeLatest(
communityActions.COMMUNITY_CREATE_ACCOUNT_ERROR,
createAccountError
),
];
export function* createAccountError(action) {
debugger;
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_PENDING,
payload: false,
});
yield put({
type: communityActions.CREATE_COMMUNITY_ERROR,
payload: true,
});
}
export function* customOps(action) {
yield put({
......@@ -64,8 +53,7 @@ export function* customOps(action) {
communityOwnerName,
communityOwnerWifPassword,
} = action.payload;
// The client cannot submit custom_json and account_create in the same block. The easiest way around this, for now, is to pause for 3 seconds after the account is created before submitting the ops.
yield call(wait, 4000);
yield call(wait, 9000);
try {
const communityOwnerPosting = auth.getPrivateKeys(
communityOwnerName,
......@@ -119,7 +107,7 @@ export function* customOps(action) {
} catch (error) {
console.log(error);
yield put({
type: communityActions.CREATE_COMMUNITY_ERROR,
type: communityActions.CREATE_COMMUNITY_ACCOUNT_ERROR,
payload: true,
});
}
......@@ -142,7 +130,6 @@ export function* createCommunityAccount(createCommunityAction) {
communityOwnerName,
communityOwnerWifPassword,
successCallback,
errorCallback,
} = createCommunityAction.payload;
const communityOwnerPosting = auth.getPrivateKeys(
......@@ -187,15 +174,16 @@ export function* createCommunityAccount(createCommunityAction) {
successCallback();
},
errorCallback: res => {
debugger;
console.log('error', res);
errorCallback(error);
},
})
);
// The client cannot submit custom_json and account_create in the same block. The easiest way around this, for now, is to pause for 3 seconds after the account is created before submitting the ops.
} catch (error) {
console.log(error);
yield put({
type: communityActions.CREATE_COMMUNITY_ERROR,
type: communityActions.CREATE_COMMUNITY_ACCOUNT_ERROR,
payload: true,
});
yield put({
......
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