-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Review Tweaks #1
Conversation
fix other minor issues
/** | ||
* @private | ||
*/ | ||
static processMethod(type, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New helper method I created to abstract commonality of all of the static methods below
return {type:"Button", data:obj}; | ||
} | ||
|
||
static isPromise(obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled this outside of the class since it wasn't class specific. It's added again below
let finalText = convo._write.reduce((acc, text) => acc.sentence(text), new Say()).toString().trim(); | ||
let finalSpeech = convo._speak.reduce((acc, text) => acc.sentence(text), new Say()).toString().trim(); | ||
let promises = []; | ||
let textWasPopulated = !!(finalText || finalSpeech); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In javascript, an empty string is falsey, so we don't need the additional variables to hold textIsNotEmpty
and speechIsNotEmpty
as long as you trim the strings above. If you don't want to trim them for some reason, you can undo the change, but given how you are using them, that doesn't seem necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the Java dev in me not used to "falsey" things =). Thanks for the tip there.
/* eslint-enable new-cap */ | ||
static prepComplete(obj, action = 'close', options) { | ||
if (isPromise(obj)) { | ||
return obj.then(result => this.prepComplete(result, action, options)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed obj
to result
in the arrow function to avoid any ambiguities on which scoped obj
was being used
return r; | ||
} | ||
setAccessToken(token) { | ||
if (!conv.user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conv
is not defined in this scope. I assumed you meant this.conv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad. Nice catch.
When you do the diff, enable the "Hide whitespace changes" setting to make it significantly easier to review