Comments and readability

This commit is contained in:
emizzle 2018-07-12 00:15:50 +10:00
parent 0be0b2d24d
commit 01273e7319
1 changed files with 17 additions and 17 deletions

View File

@ -42,17 +42,17 @@ class App extends Component {
_loadCurrentUser = async () => {
const accounts = await web3.eth.getAccounts();
try {
// get the owner associated with the current defaultAccount
const usernameHash = await DTwitter.methods.owners(accounts[0]).call();
if (usernameHash) {
// get user details from contract
const user = await DTwitter.methods.users(usernameHash).call();
// update user picture with ipfs url
user.picture = user.picture.length > 0 ? EmbarkJS.Storage.getUrl(user.picture) : imgAvatar;
// get user details from contract
const user = await DTwitter.methods.users(usernameHash).call();
// update state with user details
return this.setState({ user: user, account: accounts[0] });
}
// update user picture with ipfs url
user.picture = user.picture.length > 0 ? EmbarkJS.Storage.getUrl(user.picture) : imgAvatar;
// update state with user details
return this.setState({ user: user, account: accounts[0] });
}
catch (err) {
this.setState({ error: err });
@ -72,14 +72,14 @@ class App extends Component {
return (
<div>
<Header
user={ this.state.user }
account={ this.state.account }
error={ this.state.error } />
user={this.state.user}
account={this.state.account}
error={this.state.error} />
<Main
user={ this.state.user }
account={ this.state.account }
error={ this.state.error }
onAfterUserUpdate={ (e) => this._loadCurrentUser() } />
user={this.state.user}
account={this.state.account}
error={this.state.error}
onAfterUserUpdate={(e) => this._loadCurrentUser()} />
</div>
);
}