Skip to content

Rocketchat lib2#6593

Merged
rodrigok merged 4 commits into
RocketChat:developfrom
ggazzo:rocketchat-lib2
Apr 19, 2017
Merged

Rocketchat lib2#6593
rodrigok merged 4 commits into
RocketChat:developfrom
ggazzo:rocketchat-lib2

Conversation

@ggazzo

@ggazzo ggazzo commented Apr 4, 2017

Copy link
Copy Markdown
Member

@RocketChat/core

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

ggazzo commented Apr 10, 2017

Copy link
Copy Markdown
Member Author

@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