-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Flex-Tab CoffeeScript to JavaScript III #6278
Conversation
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.
OK, I have stopped looking for more errors, since after you make the requested changes I'll have to look all over again... please fix all ==
to ===
and !=
to !==
and double-check places where you are not checking for the existence of the variable, such as Template.instance().user.get()
(where coffeescript uses ?
to check for existence).
|
||
email() { | ||
const user = Template.instance().user.get(); | ||
if (user.emails && user.emails[0] && user.emails[0].address) { |
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.
Just as a note you may use return user.emails && user.emails[0] && user.emails[0].address;
}, | ||
|
||
canDirectMessage(username) { | ||
return RocketChat.authz.hasAllPermission('create-d') && (Meteor.user.username !== username); |
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.
This will fail: Meteor.user.username !== username
. Use Meteor.user() && Meteor.user().username !== username
;
}, | ||
|
||
isModerator() { | ||
return !!RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': Template.instance().user.get()._id, roles: 'moderator' }); |
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.
Not checking if Template.instance().user.get()
is null or undefined
}, | ||
|
||
isOwner() { | ||
return !!RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': Template.instance().user.get()._id, roles: 'owner' }); |
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.
Not checking if Template.instance().user.get()
is null or undefined
}, | ||
|
||
hasAdminRole() { | ||
return RocketChat.authz.hasRole(Template.instance().user.get()._id, 'admin'); |
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.
Not checking if Template.instance().user.get()
is null or undefined
|
||
roleTags() { | ||
const uid = Template.instance().user.get()._id; | ||
const roles = _.union(UserRoles.findOne(uid).roles, RoomRoles.findOne({'u._id': uid, rid: Session.get('openedRoom') }).roles); |
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.
Not checking if UserRoles.findOne(uid)
is null or undefined
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.
Not checking if RoomRoles.findOne({'u._id': uid, rid: Session.get('openedRoom') })
is null of undefined
closeOnConfirm: false, | ||
html: false | ||
}, () => { | ||
return Meteor.call('removeUserFromRoom', { rid, username: instance.user.get().usernamed }, (err) => { |
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.
Added a d
on instance.user.get().usernamed
const rid = Session.get('openedRoom'); | ||
//const room = ChatRoom.findOne(rid); // never used | ||
if (RocketChat.authz.hasAllPermission('mute-user', rid)) { | ||
return Meteor.call('unmuteUserInRoom', { rid, username: t.user.get().username }, function(err) { |
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.
Not checking if t.user.get()
is null or undefined
'click .set-moderator'(e, t) { | ||
e.preventDefault(); | ||
|
||
const userModerator = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': t.user.get()._id, roles: 'moderator' }, { fields: { _id: 1 } }); |
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.
Not checking if t.instance().user.get()
is null or undefined
e.preventDefault(); | ||
|
||
const userModerator = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': t.user.get()._id, roles: 'moderator' }, { fields: { _id: 1 } }); | ||
if (userModerator == null) { |
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.
Using ==
instead of ===
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.
Also check for undefined
@marceloschmidt changed some things could you do a review again? Thanks! |
}, | ||
|
||
canDirectMessage(username) { | ||
return RocketChat.authz.hasAllPermission('create-d') && (Meteor.user && Meteor.user.username !== username); |
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.
Meteor.user is a function
|
||
linkedinUsername() { | ||
const user = Template.instance().user.get(); | ||
if (user.services && user.services.linkedin && user.services.linkedin.publicProfileUrl) { |
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.
user
can be undefined
}, | ||
|
||
roleTags() { | ||
const uid = Template.instance().user.get()._id; |
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.
Template.instance().user.get()
can be null
roleTags() { | ||
const uid = Template.instance().user.get()._id; | ||
if (uid) { | ||
const roles = _.union(UserRoles.findOne(uid).roles, RoomRoles.findOne({'u._id': uid, rid: Session.get('openedRoom') }).roles); |
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.
UserRoles.findOne(uid)
can be null
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.
RoomRoles.findOne({'u._id': uid, rid: Session.get('openedRoom') })
can be null
closeOnConfirm: false, | ||
html: false | ||
}, () => { | ||
return Meteor.call('removeUserFromRoom', { rid, username: instance.user.get().username }, (err) => { |
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.
instance.user.get()
can be null
'click .unset-moderator'(e, t) { | ||
e.preventDefault(); | ||
const user = t.user.get(); | ||
const userModerator = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': user._id, roles: 'moderator' }, { fields: { _id: 1 } }); |
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.
user
can be null
'click .set-owner'(e, t) { | ||
e.preventDefault(); | ||
const user = t.user.get(); | ||
const userOwner = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': user._id, roles: 'owner' }, { fields: { _id: 1 } }); |
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.
user
can be null
'click .unset-owner'(e, t) { | ||
e.preventDefault(); | ||
const user = t.user.get(); | ||
const userOwner = RoomRoles.findOne({ rid: Session.get('openedRoom'), 'u._id': user._id, roles: 'owner' }, { fields: { _id: 1 } }); |
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.
user
can be null
html: false | ||
}, function() { | ||
swal.disableButtons(); | ||
return Meteor.call('deleteUser', user._id, function(error) { |
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.
user
can be null
this.autorun(() => { | ||
username = this.loadedUsername.get(); | ||
|
||
if ((username == null)) { |
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.
Why ((
?
@marceloschmidt can you review again? |
Template.userInfo.helpers({ | ||
name() { | ||
const user = Template.instance().user.get(); | ||
return user.name ? user.name : TAPi18n.__('Unnamed'); |
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.
return user && user.name ? user.name : TAPi18n.__('Unnamed');
@RocketChat/core
Please let me know if i left anything wrong, since this is a big file.