Skip to content
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

Rocketchat lib2 #6593

Merged
merged 4 commits into from
Apr 19, 2017
Merged

Rocketchat lib2 #6593

merged 4 commits into from
Apr 19, 2017

Conversation

ggazzo
Copy link
Member

@ggazzo ggazzo commented Apr 4, 2017

@RocketChat/core

});
}
const cursor = RocketChat.models[model][method].apply(RocketChat.models[model], args);
return cursor && cursor.fetch && cursor.fetch();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return undefined when calling a findOne.

The called method could return a object or undefined from a findOne result or a cursor from a find result.
So the cursor can be an object from a record or an object from a cursor or undefined.

If the result is and cursor, that is ok, the fetch is the desired method to execute to get the data.
If the result is and object from a findOne you will return a property called fetch as undefined or will throw and error trying to execute the property as a function.

Take a look at the old code and try to use the same logic here

let msgTs;
let currentTsDiff;
const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
if ((blockDeleteInMinutes != null) && blockDeleteInMinutes !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this extra parenthesis

msgTs = moment(originalMessage.ts);
}
if (msgTs != null) {
currentTsDiff = moment().diff(msgTs, 'minutes');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use can use const for msgTs and currentTsDiff and put the ifs chained

@ggazzo
Copy link
Member Author

ggazzo commented Apr 10, 2017

@rodrigok , it's done.

@engelgabriel engelgabriel modified the milestone: 0.56.0 Apr 18, 2017
@rodrigok rodrigok merged commit 752aef3 into RocketChat:develop Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants