Skip to content

Commit

Permalink
Now tells user if verified isn't in contacts (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Cash committed Aug 17, 2016
1 parent dc0115f commit dd99f84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/components/composer/ComposerForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ class ComposerForm extends Component {

handleVerify = async () => {
const match = await this._pgp(verify, this.props.keychain)()
this.props.setOutput(`Signed message is verified to match: ${ match.name } <${ match.email }>`)
if(typeof match.name === "undefined"){

This comment has been minimized.

Copy link
@tejasmanohar

tejasmanohar Aug 19, 2016

Collaborator

why typeof? :P

This comment has been minimized.

Copy link
@frankcash

frankcash Aug 19, 2016

Collaborator

Because that property is undefined at that point if they aren't in your friend's list. I'm open to suggestions though!

This comment has been minimized.

Copy link
@maxence-lefebvre

maxence-lefebvre Aug 19, 2016

Why not using a one-liner with a ternary operator then ?
Is any of the possible falsy values a valid value ? ('', null, undefined, 0, false, NaN) ?

this.props.setOutput(match.name ? `Signed message is verified to match: ${ match.name } <${ match.email }>` : 'The author of this message appears to not be in your contact list');

This comment has been minimized.

Copy link
@frankcash

frankcash Aug 19, 2016

Collaborator

Good catch, I try not to use ternary operators due to previous experiences ruling them out for complexity's sake when working on larger code bases.

This comment has been minimized.

Copy link
@maxence-lefebvre

maxence-lefebvre Aug 19, 2016

I am sorry I edited my post while you were answering !

I agree with you, I have to work with huge codebases as well but I think as long as you don't nest them, they can increase the readabilty of your code.

For example, here with the if/else syntax, at first glance you may think you are going to do two different things. With the ternary operator syntax, at first glance you see that we are going to call this.props.setOutput, which was the main purpose of your function.

This comment has been minimized.

Copy link
@tejasmanohar

tejasmanohar Aug 19, 2016

Collaborator

oh i meant typeof vs just === undefined works but nitpick :P

This comment has been minimized.

Copy link
@frankcash

frankcash Aug 19, 2016

Collaborator

I guess it's just habit for me to reach for the typeof in that situation :)

this.props.setOutput('The author of this message appears to not be in your contact list')
}else{
this.props.setOutput(`Signed message is verified to match: ${ match.name } <${ match.email }>`)
}
}

getProps = () => {
Expand Down

0 comments on commit dd99f84

Please sign in to comment.