Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hive
wallet
Commits
197b1361
Commit
197b1361
authored
Sep 15, 2019
by
/ /\ / /\/
Browse files
Revert "wip, handle errors in community creation"
This reverts commit
dcd1b297
.
parent
7bc0106a
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/app/components/elements/CreateCommunity.jsx
View file @
197b1361
...
...
@@ -5,238 +5,203 @@ import * as communityActions from 'app/redux/CommunityReducer';
import
tt
from
'
counterpart
'
;
import
{
key_utils
}
from
'
@steemit/steem-js/lib/auth/ecc
'
;
class
CreateCommunity
extends
React
.
Component
{
constructor
()
{
super
();
this
.
state
=
{
error
:
false
};
}
render
()
{
const
errorCB
=
()
=>
{
debugger
;
// Can we dispatch from within here.
this
.
setState
({
error
:
true
});
};
const
CreateCommunity
=
({
accountName
,
communityCreateError
,
communityCreatePending
,
communityCreateSuccess
,
createCommunity
,
communityDescription
,
communityNSFW
,
communityOwnerWifPassword
,
communityOwnerName
,
communityTitle
,
updateCommunityTitle
,
updateCommunityDescription
,
updateCommunityNSFW
,
updateCommunityOwnerAccountName
,
updateCommunityOwnerWifPassword
,
communityHivemindOperationPending
,
communityHivemindOperationError
,
})
=>
{
const
handleCommunityTitleInput
=
e
=>
{
if
(
e
.
target
.
value
.
length
>
32
)
{
return
;
}
updateCommunityTitle
(
e
.
target
.
value
);
};
const
handleCommunityDescriptionInput
=
e
=>
{
if
(
e
.
target
.
value
.
length
>
120
)
{
return
;
}
updateCommunityDescription
(
e
.
target
.
value
);
};
const
handleCommunityNSFWInput
=
e
=>
{
updateCommunityNSFW
(
e
.
target
.
checked
);
};
const
{
const
handleCommunitySubmit
=
e
=>
{
e
.
preventDefault
();
const
createCommunitypayload
=
{
accountName
,
communityCreateError
,
communityCreatePending
,
communityCreateSuccess
,
createCommunity
,
communityTitle
,
communityDescription
,
communityNSFW
,
communityOwnerWifPassword
,
communityOwnerName
,
communityTitle
,
updateCommunityTitle
,
updateCommunityDescription
,
updateCommunityNSFW
,
updateCommunityOwnerAccountName
,
updateCommunityOwnerWifPassword
,
communityHivemindOperationPending
,
communityHivemindOperationError
,
loginError
,
transactionState
,
hasTransactionError
,
}
=
this
.
props
;
console
.
log
(
this
.
state
.
error
);
const
handleCommunityTitleInput
=
e
=>
{
if
(
e
.
target
.
value
.
length
>
32
)
{
return
;
}
updateCommunityTitle
(
e
.
target
.
value
);
};
const
handleCommunityDescriptionInput
=
e
=>
{
if
(
e
.
target
.
value
.
length
>
120
)
{
return
;
}
updateCommunityDescription
(
e
.
target
.
value
);
};
const
handleCommunityNSFWInput
=
e
=>
{
updateCommunityNSFW
(
e
.
target
.
checked
);
communityOwnerWifPassword
,
};
createCommunity
(
createCommunitypayload
);
};
const
handleCommunitySubmit
=
e
=>
{
e
.
preventDefault
();
const
createCommunitypayload
=
{
accountName
,
communityTitle
,
communityDescription
,
communityNSFW
,
communityOwnerName
,
communityOwnerWifPassword
,
};
createCommunity
(
createCommunitypayload
,
errorCB
);
};
const
generateCommunityOwnerName
=
()
=>
{
return
`hive-
${
Math
.
floor
(
Math
.
random
()
*
100000
)
+
100000
}
`
;
};
const
generateC
ommunityOwnerName
=
()
=>
{
return
`hive-
${
Math
.
floor
(
Math
.
random
()
*
100000
)
+
100000
}
`
;
};
const
generateC
reatorWifPassword
=
()
=>
{
return
'
P
'
+
key_utils
.
get_random_key
().
toWif
()
;
};
const
generateCreatorWifPassword
=
()
=>
{
return
'
P
'
+
key_utils
.
get_random_key
().
toWif
();
};
const
generateWif
=
()
=>
{
const
wif
=
generateCreatorWifPassword
();
updateCommunityOwnerWifPassword
(
wif
);
};
const
generate
Wif
=
()
=>
{
const
wif
=
generateCreatorWifPassword
();
updateCommunityOwner
WifPassword
(
wif
);
};
const
generate
Username
=
()
=>
{
const
ownerUsername
=
generateCommunityOwnerName
();
updateCommunityOwner
AccountName
(
ownerUsername
);
};
const
generate
Username
=
()
=>
{
const
ownerUsername
=
generateCommunityOwnerName
();
updateCommunityOwnerAccountName
(
owner
Username
);
};
const
generate
CommunityCredentials
=
()
=>
{
generateWif
();
generate
Username
(
);
};
const
generateCommunityCredentials
=
()
=>
{
generateWif
();
generateUsername
();
};
const
generateCommunityCredentialsButton
=
(
<
button
type
=
"button"
className
=
"button hollow"
onClick
=
{
generateCommunityCredentials
}
>
{
tt
(
'
g.click_to_generate_password
'
)
}
</
button
>
);
const
generateCommunityCredentialsButton
=
(
<
button
type
=
"button"
className
=
"button hollow"
onClick
=
{
generateCommunityCredentials
}
>
{
tt
(
'
g.click_to_generate_password
'
)
}
</
button
>
);
const
rememberCredentialsPrompt
=
(
<
div
>
<
div
>
{
`
${
tt
(
'
g.community_owner_name_is
'
)}
:
${
communityOwnerName
}
`
}
</
div
>
<
div
>
{
`
${
tt
(
'
g.community_password_is
'
)}
:
${
communityOwnerWifPassword
}
`
}
</
div
>
</
div
>
);
const
rememberCredentialsPrompt
=
(
<
div
>
<
div
>
{
`
${
tt
(
'
g.community_owner_name_is
'
)}
:
${
communityOwnerName
}
`
}
</
div
>
<
div
>
{
`
${
tt
(
'
g.community_password_is
'
)}
:
${
communityOwnerWifPassword
}
`
}
</
div
>
</
div
>
);
const
rememberCredentialsCheckbox1
=
(
<
label
htmlFor
=
"box1"
>
<
input
type
=
"checkbox"
name
=
"box1"
required
/>
{
tt
(
'
g.understand_that_APP_NAME_cannot_recover_password
'
,
{
APP_NAME
,
})
}
.
</
label
>
);
const
rememberCredentialsCheckbox1
=
(
<
label
htmlFor
=
"box1"
>
<
input
type
=
"checkbox"
name
=
"box1"
required
/>
{
tt
(
'
g.understand_that_APP_NAME_cannot_recover_password
'
,
{
APP_NAME
,
})
}
.
</
label
>
);
const
rememberCredentialsCheckbox2
=
(
<
label
htmlFor
=
"box2"
>
<
input
type
=
"checkbox"
name
=
"box2"
required
/>
{
tt
(
'
g.i_saved_password
'
)
}
.
</
label
>
);
const
rememberCredentialsCheckbox2
=
(
<
label
htmlFor
=
"box2"
>
<
input
type
=
"checkbox"
name
=
"box2"
required
/>
{
tt
(
'
g.i_saved_password
'
)
}
.
</
label
>
);
const
submitCreateCommunityFormButton
=
(
<
input
type
=
"submit"
value
=
"Submit"
/>
);
const
submitCreateCommunityFormButton
=
(
<
input
type
=
"submit"
value
=
"Submit"
/>
);
const
createCommunitySuccessMessage
=
(
<
div
>
<
p
>
Your community was created!
</
p
>
<
a
href
=
{
`https://steemitdev.com/trending/
${
communityOwnerName
}
`
}
>
{
tt
(
'
g.community_visit
'
)
}
</
a
>
</
div
>
);
const
createCommunitySuccessMessage
=
(
<
div
>
<
p
>
Your community was created!
</
p
>
<
a
href
=
{
`https://steemitdev.com/trending/
${
communityOwnerName
}
`
}
>
{
tt
(
'
g.community_visit
'
)
}
</
a
>
</
div
>
);
const
createCommunityErrorMessage
=
(
<
div
>
{
tt
(
'
g.community_error
'
)
}
</
div
>
);
const
createCommunityLoadingMessage
=
(
<
div
>
{
tt
(
'
g.community_creating
'
)
}
</
div
>
);
const
createCommunityPasswordError
=
(
<
div
>
<
div
>
{
tt
(
'
g.community_create_password_error
'
)
}
</
div
>
<
div
>
{
loginError
}
</
div
>
</
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
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
createCommunityForm
=
(
<
form
onSubmit
=
{
handleCommunitySubmit
}
>
<
div
>
{
tt
(
'
g.community_create
'
)
}
</
div
>
<
label
htmlFor
=
"community_title"
>
Title
<
input
id
=
"community_title"
name
=
"community_title"
type
=
"text"
minLength
=
"4"
maxLength
=
"30"
onChange
=
{
handleCommunityTitleInput
}
value
=
{
communityTitle
}
required
/>
</
label
>
<
label
htmlFor
=
"community_description"
>
{
tt
(
'
g.community_description
'
)
}
<
input
id
=
"community_description"
name
=
"community_description"
type
=
"text"
minLength
=
"10"
maxLength
=
"140"
onChange
=
{
handleCommunityDescriptionInput
}
value
=
{
communityDescription
}
required
/>
</
label
>
<
label
id
=
"is_nsfw"
htmlFor
=
"is_nsfw"
>
{
tt
(
'
g.community_nsfw
'
)
}
<
input
type
=
"checkbox"
name
=
"is_nsfw"
checked
=
{
communityNSFW
}
onChange
=
{
handleCommunityNSFWInput
}
/>
</
label
>
{
communityOwnerWifPassword
.
length
<=
0
&&
generateCommunityCredentialsButton
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsPrompt
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox1
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox2
}
{
communityOwnerWifPassword
.
length
>
0
&&
submitCreateCommunityFormButton
}
</
form
>
);
return
(
<
div
className
=
"row"
>
<
div
className
=
"column large-6 small-12"
>
{
loginError
&&
createCommunityPasswordError
}
{
hasTransactionError
&&
<
div
>
THERE WAS AN ERROR!
</
div
>
}
{
!
communityCreatePending
&&
!
communityCreateSuccess
&&
createCommunityForm
}
{
communityCreatePending
&&
createCommunityLoadingMessage
}
{
communityHivemindOperationPending
&&
createCommunityCustomOpsPendingMessage
}
{
communityCreateSuccess
&&
createCommunitySuccessMessage
}
{
communityCreateError
&&
createCommunityErrorMessage
}
</
div
>
const
createCommunityForm
=
(
<
form
onSubmit
=
{
handleCommunitySubmit
}
>
<
div
>
{
tt
(
'
g.community_create
'
)
}
</
div
>
<
label
htmlFor
=
"community_title"
>
Title
<
input
id
=
"community_title"
name
=
"community_title"
type
=
"text"
minLength
=
"4"
maxLength
=
"30"
onChange
=
{
handleCommunityTitleInput
}
value
=
{
communityTitle
}
required
/>
</
label
>
<
label
htmlFor
=
"community_description"
>
{
tt
(
'
g.community_description
'
)
}
<
input
id
=
"community_description"
name
=
"community_description"
type
=
"text"
minLength
=
"10"
maxLength
=
"140"
onChange
=
{
handleCommunityDescriptionInput
}
value
=
{
communityDescription
}
required
/>
</
label
>
<
label
id
=
"is_nsfw"
htmlFor
=
"is_nsfw"
>
{
tt
(
'
g.community_nsfw
'
)
}
<
input
type
=
"checkbox"
name
=
"is_nsfw"
checked
=
{
communityNSFW
}
onChange
=
{
handleCommunityNSFWInput
}
/>
</
label
>
{
communityOwnerWifPassword
.
length
<=
0
&&
generateCommunityCredentialsButton
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsPrompt
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox1
}
{
communityOwnerWifPassword
.
length
>
0
&&
rememberCredentialsCheckbox2
}
{
communityOwnerWifPassword
.
length
>
0
&&
submitCreateCommunityFormButton
}
</
form
>
);
return
(
<
div
className
=
"row"
>
<
div
className
=
"column large-6 small-12"
>
{
!
communityCreatePending
&&
!
communityCreateSuccess
&&
createCommunityForm
}
{
communityCreatePending
&&
createCommunityLoadingMessage
}
{
communityHivemindOperationPending
&&
createCommunityCustomOpsPendingMessage
}
{
communityCreateSuccess
&&
createCommunitySuccessMessage
}
{
communityCreateError
&&
createCommunityErrorMessage
}
</
div
>
);
}
}
</
div
>
);
}
;
export
default
connect
(
// mapStateToProps
...
...
@@ -244,15 +209,6 @@ export default connect(
const
{
account
}
=
ownProps
;
const
accountName
=
account
.
get
(
'
name
'
);
const
current
=
state
.
user
.
get
(
'
current
'
);
// get userLogin error
console
.
log
(
'
userState
'
,
state
.
user
.
toJS
());
console
.
log
(
'
transactionState
'
,
state
.
transaction
.
toJS
());
const
loginError
=
state
.
user
.
toJS
().
login_error
;
const
transactionState
=
state
.
transaction
.
toJS
();
const
hasTransactionError
=
Object
.
values
(
state
.
transaction
.
toJS
().
errors
).
filter
(
v
=>
!!
v
)
.
length
>
0
;
console
.
log
(
'
There was a transaction error:
'
,
hasTransactionError
);
const
username
=
current
&&
current
.
get
(
'
username
'
);
const
isMyAccount
=
username
===
accountName
;
return
{
...
...
@@ -260,9 +216,6 @@ export default connect(
...
state
.
community
.
toJS
(),
isMyAccount
,
accountName
,
loginError
,
transactionState
,
hasTransactionError
,
};
},
// mapDispatchToProps
...
...
@@ -287,16 +240,17 @@ export default connect(
communityActions
.
setCommunityOwnerWifPassword
(
password
)
);
},
createCommunity
:
(
createCommunityPayload
,
errorCB
)
=>
{
createCommunity
:
createCommunityPayload
=>
{
const
successCallback
=
()
=>
dispatch
(
communityActions
.
communityHivemindOperation
(
createCommunityPayload
)
);
const
errorCallback
=
()
=>
{
errorCB
();
};
const
errorCallback
=
()
=>
dispatch
(
communityActions
.
createCommunityAccountError
(
true
)
);
const
payload
=
{
successCallback
:
successCallback
,
errorCallback
:
errorCallback
,
...
...
src/app/locales/en.json
View file @
197b1361
...
...
@@ -25,8 +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_create_password_error"
:
"There was a problem with your credentials:"
,
"community_broadcasting_custom_ops"
:
"Making"
,
"community_broadcasting_custom_ops_1"
:
"administrator of the"
,
"community_broadcasting_custom_ops_2"
:
"community."
,
...
...
src/app/redux/CommunityReducer.js
View file @
197b1361
...
...
@@ -75,7 +75,6 @@ export default function reducer(state = defaultState, action) {
}
case
CREATE_COMMUNITY_ERROR
:
{
const
err
=
fromJS
(
payload
);
debugger
;
return
state
.
merge
({
communityCreateError
:
err
});
}
case
CREATE_COMMUNITY_SUCCESS
:
{
...
...
@@ -137,13 +136,10 @@ export const createCommunityAccountPending = payload => ({
payload
,
});
export
const
createCommunityAccountError
=
payload
=>
{
debugger
;
return
{
type
:
CREATE_COMMUNITY_ACCOUNT_ERROR
,
payload
,
};
};
export
const
createCommunityAccountError
=
payload
=>
({
type
:
CREATE_COMMUNITY_ACCOUNT_ERROR
,
payload
,
});
export
const
createCommunitySuccess
=
payload
=>
({
type
:
CREATE_COMMUNITY_SUCCESS
,
...
...
src/app/redux/CommunitySaga.js
View file @
197b1361
...
...
@@ -35,7 +35,7 @@ export const communityWatches = [
),
takeLatest
(
communityActions
.
COMMUNITY_HIVEMIND_OPERATION
,
customOps
),
takeLatest
(
communityActions
.
CREATE_
COMMUNITY_ACCOUNT_ERROR
,
communityActions
.
COMMUNITY_
CREATE_
ACCOUNT_ERROR
,
createAccountError
),
];
...
...
@@ -189,7 +189,7 @@ export function* createCommunityAccount(createCommunityAction) {
errorCallback
:
res
=>
{
debugger
;
console
.
log
(
'
error
'
,
res
);
errorCallback
(
res
);
errorCallback
(
error
);
},
})
);
...
...
src/app/redux/TransactionReducer.js
View file @
197b1361
...
...
@@ -28,7 +28,6 @@ export default function reducer(state = defaultState, action) {
const
operation
=
fromJS
(
payload
.
operation
);
const
confirm
=
payload
.
confirm
;
const
warning
=
payload
.
warning
;
debugger
;
return
state
.
merge
({
show_confirm_modal
:
true
,
confirmBroadcastOperation
:
operation
,
...
...
src/app/redux/TransactionSaga.js
View file @
197b1361
...
...
@@ -132,7 +132,6 @@ export function* broadcastOperation({
const
warning
=
tt
(
'
g.post_key_warning.warning
'
);
const
checkbox
=
tt
(
'
g.post_key_warning.checkbox
'
);
operationParam
.
allowPostUnsafe
=
true
;
debugger
;
yield
put
(
transactionActions
.
confirmOperation
({
confirm
,
...
...
@@ -183,7 +182,6 @@ export function* broadcastOperation({
serverApiRecordEvent
(
eventType
,
page
);
}
catch
(
error
)
{
console
.
error
(
'
TransactionSage
'
,
error
);
debugger
;
if
(
errorCallback
)
errorCallback
(
error
.
toString
());
}
}
...
...
src/app/redux/UserReducer.js
View file @
197b1361
...
...
@@ -49,7 +49,6 @@ const defaultState = fromJS({
locale
:
DEFAULT_LANGUAGE
,
show_side_panel
:
false
,
maybeLoggedIn
:
false
,
login_error
:
undefined
,
});
export
default
function
reducer
(
state
=
defaultState
,
action
)
{
...
...
@@ -203,7 +202,6 @@ export default function reducer(state = defaultState, action) {
});
case
LOGIN_ERROR
:
debugger
;
return
state
.
merge
({
login_error
:
payload
.
error
,
logged_out
:
undefined
,
...
...
src/app/redux/UserSaga.js
View file @
197b1361
...
...
@@ -219,7 +219,6 @@ function* usernamePasswordLogin({
Set
()
);
if
(
!
fullAuths
.
size
)
{
debugger
;
console
.
log
(
'
No full auths
'
);
localStorage
.
removeItem
(
'
autopost2
'
);
const
generated_type
=
password
[
0
]
===
'
P
'
&&
password
.
length
>
40
;
...
...
@@ -419,8 +418,12 @@ function* logout(action) {
yield
serverApiLogout
();
}
function
*
loginError
()
{
yield
serverApiLogout
();
function
*
loginError
({
payload
:
{
/*error*/
},
})
{
serverApiLogout
();
}
/**
...
...
src/app/utils/ServerApiClient.js
View file @
197b1361
...
...
@@ -23,7 +23,6 @@ export function serverApiLogout() {
const
request
=
Object
.
assign
({},
request_base
,
{
body
:
JSON
.
stringify
({
csrf
:
$STM_csrf
}),
});
debugger
;
return
fetch
(
'
/api/v1/logout_account
'
,
request
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment