Skip to content

rocketchat-channel-settings coffee to js#6551

Merged
engelgabriel merged 5 commits into
RocketChat:developfrom
ggazzo:rocketchat-channel-settings
Apr 3, 2017
Merged

rocketchat-channel-settings coffee to js#6551
engelgabriel merged 5 commits into
RocketChat:developfrom
ggazzo:rocketchat-channel-settings

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Mar 31, 2017

No description provided.

constructor() {
this.options = new ReactiveVar({});
}
addOption(config) {
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.

Can you keep the comments?

this.options = new ReactiveVar({});
}
addOption(config) {
if (!(config && config.id)) {
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.

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

});
}
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
Copy Markdown
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