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-channel-settings coffee to js #6551

Merged
merged 5 commits into from
Apr 3, 2017

Conversation

ggazzo
Copy link
Member

@ggazzo ggazzo commented Mar 31, 2017

No description provided.

constructor() {
this.options = new ReactiveVar({});
}
addOption(config) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you keep the comments?

this.options = new ReactiveVar({});
}
addOption(config) {
if (!(config && config.id)) {
Copy link
Member

Choose a reason for hiding this comment

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

if (config == null || config.id == null) {

getOptions(currentData, group) {
const allOptions = _.toArray(this.options.get());
const allowedOptions = _.compact(_.map(allOptions, function(option) {
if ((option.validation == null) || option.validation()) {
Copy link
Member

Choose a reason for hiding this comment

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

Remove the extra parenthesis

const allOptions = _.toArray(this.options.get());
const allowedOptions = _.compact(_.map(allOptions, function(option) {
if ((option.validation == null) || option.validation()) {
option.data = Object.assign(option.data || {}, currentData);
Copy link
Member

Choose a reason for hiding this comment

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

option.data = Object.assign({}, option.data, currentData);

},
canView(room) {
let ref;
if ((ref = room.t) !== 'c' && ref !== 'p') {
Copy link
Member

Choose a reason for hiding this comment

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

if (['c', 'p'].includes(room.t) === false) {

let action;
swal.disableButtons();
if (confirmed) {
action = value ? 'archiveRoom' : 'unarchiveRoom';
Copy link
Member

Choose a reason for hiding this comment

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

Declare the variable here

@@ -0,0 +1,44 @@

RocketChat.saveRoomType = function(rid, roomType, user, sendMessage = true) {
if (sendMessage == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Remove this

let message;
const result = RocketChat.models.Rooms.setTypeById(rid, roomType) && RocketChat.models.Subscriptions.updateTypeByRoomId(rid, roomType);
if (result && sendMessage) {
if (roomType === 'c') {
Copy link
Member

Choose a reason for hiding this comment

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

Move the let message to here

method: 'saveRoomSettings'
});
}
if (setting !== 'roomName' && setting !== 'roomTopic' && setting !== 'roomAnnouncement' && setting !== 'roomDescription' && setting !== 'roomType' && setting !== 'readOnly' && setting !== 'reactWhenReadOnly' && setting !== 'systemMessages' && setting !== 'default' && setting !== 'joinCode') {
Copy link
Member

Choose a reason for hiding this comment

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

Use an array to reduce this condition

@@ -10,7 +10,7 @@ Meteor.methods({
method: 'saveRoomSettings'
});
}
if (setting !== 'roomName' && setting !== 'roomTopic' && setting !== 'roomAnnouncement' && setting !== 'roomDescription' && setting !== 'roomType' && setting !== 'readOnly' && setting !== 'reactWhenReadOnly' && setting !== 'systemMessages' && setting !== 'default' && setting !== 'joinCode') {
if (!['roomName', 'roomTopic', 'roomAnnouncement', 'roomDescription', 'roomType', 'readOnly', 'reactWhenReadOnly', 'systemMessages', 'default', 'joinCode'].some((s) => s === setting)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why some instead of includes?

@rodrigok rodrigok added this to the 0.55.0 milestone Apr 3, 2017
@engelgabriel engelgabriel merged commit 9572a21 into RocketChat:develop Apr 3, 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