Skip to content

Commit

Permalink
Remove all uncessary isSetNotNull
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Feb 8, 2017
1 parent 120d47e commit e1c4214
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 84 deletions.
14 changes: 7 additions & 7 deletions packages/rocketchat-custom-sounds/admin/adminSounds.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals isSetNotNull, RocketChatTabBar */
/* globals RocketChatTabBar */
Template.adminSounds.helpers({
isReady() {
if (isSetNotNull(() => Template.instance().ready)) {
if (Template.instance().ready != null) {
return Template.instance().ready.get();
}
return undefined;
Expand All @@ -10,14 +10,14 @@ Template.adminSounds.helpers({
return Template.instance().customsounds();
},
isLoading() {
if (isSetNotNull(() => Template.instance().ready)) {
if (Template.instance().ready != null) {
if (!Template.instance().ready.get()) {
return 'btn-loading';
}
}
},
hasMore() {
if (isSetNotNull(() => Template.instance().limit)) {
if (Template.instance().limit != null) {
if (typeof Template.instance().customsounds === 'function') {
return Template.instance().limit.get() === Template.instance().customsounds().length;
}
Expand Down Expand Up @@ -65,13 +65,13 @@ Template.adminSounds.onCreated(function() {
});

this.autorun(function() {
const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0;
const limit = (instance.limit != null) ? instance.limit.get() : 0;
const subscription = instance.subscribe('customSounds', '', limit);
instance.ready.set(subscription.ready());
});

this.customsounds = function() {
const filter = (isSetNotNull(() => instance.filter))? _.trim(instance.filter.get()) : '';
const filter = (instance.filter != null) ? _.trim(instance.filter.get()) : '';

let query = {};

Expand All @@ -80,7 +80,7 @@ Template.adminSounds.onCreated(function() {
query = { name: filterReg };
}

const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0;
const limit = (instance.limit != null) ? instance.limit.get() : 0;

return RocketChat.models.CustomSounds.find(query, { limit: limit, sort: { name: 1 }}).fetch();
};
Expand Down
12 changes: 6 additions & 6 deletions packages/rocketchat-custom-sounds/admin/soundEdit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toastr from 'toastr';
/* globals isSetNotNull */

Template.soundEdit.helpers({
sound() {
return Template.instance().sound;
Expand All @@ -25,10 +25,10 @@ Template.soundEdit.events({
},

'change input[type=file]'(ev) {
const e = (isSetNotNull(() => ev.originalEvent)) ? ev.originalEvent : ev;
const e = (ev.originalEvent != null) ? ev.originalEvent : ev;
let files = e.target.files;
if (!isSetNotNull(() => e.target.files) || files.length === 0) {
if (isSetNotNull(() => e.dataTransfer.files)) {
if (e.target.files == null || files.length === 0) {
if (e.dataTransfer.files != null) {
files = e.dataTransfer.files;
} else {
files = [];
Expand All @@ -45,7 +45,7 @@ Template.soundEdit.events({
});

Template.soundEdit.onCreated(function() {
if (isSetNotNull(() => this.data)) {
if (this.data != null) {
this.sound = this.data.sound;
} else {
this.sound = undefined;
Expand All @@ -62,7 +62,7 @@ Template.soundEdit.onCreated(function() {

this.getSoundData = () => {
const soundData = {};
if (isSetNotNull(() => this.sound)) {
if (this.sound != null) {
soundData._id = this.sound._id;
soundData.previousName = this.sound.name;
soundData.extension = this.sound.extension;
Expand Down
13 changes: 6 additions & 7 deletions packages/rocketchat-custom-sounds/admin/soundInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* globals isSetNotNull */
Template.soundInfo.helpers({
name() {
const sound = Template.instance().sound.get();
Expand All @@ -22,9 +21,9 @@ Template.soundInfo.helpers({
back(name) {
instance.editingSound.set();

if (isSetNotNull(() => name)) {
if (name != null) {
const sound = instance.sound.get();
if (isSetNotNull(() => sound.name) && sound.name !== name) {
if (sound.name != null && sound.name !== name) {
return instance.loadedName.set(name);
}
}
Expand All @@ -38,7 +37,7 @@ Template.soundInfo.events({
e.stopPropagation();
e.preventDefault();
const sound = instance.sound.get();
if (isSetNotNull(() => sound)) {
if (sound != null) {
const _id = sound._id;
swal({
title: t('Are_you_sure'),
Expand Down Expand Up @@ -91,17 +90,17 @@ Template.soundInfo.onCreated(function() {

this.autorun(() => {
const data = Template.currentData();
if (isSetNotNull(() => data.clear)) {
if (data.clear != null) {
this.clear = data.clear;
}
});

this.autorun(() => {
const data = Template.currentData();
const sound = this.sound.get();
if (isSetNotNull(() => sound.name)) {
if (sound.name != null) {
this.loadedName.set(sound.name);
} else if (isSetNotNull(() => data.name)) {
} else if (data.name != null) {
this.loadedName.set(data.name);
}
});
Expand Down
25 changes: 0 additions & 25 deletions packages/rocketchat-custom-sounds/function-isSet.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/rocketchat-custom-sounds/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Package.onUse(function(api) {

api.use('kadira:flow-router', 'client');

api.addFiles('function-isSet.js');

api.addFiles('server/startup/custom-sounds.js', 'server');
api.addFiles('server/startup/permissions.js', 'server');
api.addFiles('server/startup/settings.js', 'server');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals isSetNotNull, RocketChatFileCustomSoundsInstance */
/* globals RocketChatFileCustomSoundsInstance */
Meteor.methods({
deleteCustomSound(_id) {
let sound = null;
Expand All @@ -9,7 +9,7 @@ Meteor.methods({
throw new Meteor.Error('not_authorized');
}

if (!isSetNotNull(() => sound)) {
if (sound == null) {
throw new Meteor.Error('Custom_Sound_Error_Invalid_Sound', 'Invalid sound', { method: 'deleteCustomSound' });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals isSetNotNull, RocketChatFileCustomSoundsInstance */
/* globals RocketChatFileCustomSoundsInstance */
Meteor.startup(function() {
let storeType = 'GridFS';

Expand All @@ -8,14 +8,14 @@ Meteor.startup(function() {

const RocketChatStore = RocketChatFile[storeType];

if (!isSetNotNull(() => RocketChatStore)) {
if (RocketChatStore == null) {
throw new Error(`Invalid RocketChatStore type [${storeType}]`);
}

console.log(`Using ${storeType} for custom sounds storage`.green);

let path = '~/uploads';
if (isSetNotNull(() => RocketChat.settings.get('CustomSounds_FileSystemPath'))) {
if (RocketChat.settings.get('CustomSounds_FileSystemPath') != null) {
if (RocketChat.settings.get('CustomSounds_FileSystemPath').trim() !== '') {
path = RocketChat.settings.get('CustomSounds_FileSystemPath');
}
Expand Down Expand Up @@ -47,12 +47,12 @@ Meteor.startup(function() {
res.setHeader('Content-Disposition', 'inline');

let fileUploadDate = undefined;
if (isSetNotNull(() => file.uploadDate)) {
if (file.uploadDate != null) {
fileUploadDate = file.uploadDate.toUTCString();
}

const reqModifiedHeader = req.headers['if-modified-since'];
if (isSetNotNull(() => reqModifiedHeader)) {
if (reqModifiedHeader != null) {
if (reqModifiedHeader === fileUploadDate) {
res.setHeader('Last-Modified', reqModifiedHeader);
res.writeHead(304);
Expand All @@ -63,7 +63,7 @@ Meteor.startup(function() {

res.setHeader('Cache-Control', 'public, max-age=0');
res.setHeader('Expires', '-1');
if (isSetNotNull(() => fileUploadDate)) {
if (fileUploadDate != null) {
res.setHeader('Last-Modified', fileUploadDate);
} else {
res.setHeader('Last-Modified', new Date().toUTCString());
Expand Down
14 changes: 7 additions & 7 deletions packages/rocketchat-emoji-custom/admin/adminEmoji.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals isSetNotNull, RocketChatTabBar */
/* globals RocketChatTabBar */
Template.adminEmoji.helpers({
isReady() {
if (isSetNotNull(() => Template.instance().ready)) {
if (Template.instance().ready != null) {
return Template.instance().ready.get();
}
return undefined;
Expand All @@ -10,14 +10,14 @@ Template.adminEmoji.helpers({
return Template.instance().customemoji();
},
isLoading() {
if (isSetNotNull(() => Template.instance().ready)) {
if (Template.instance().ready != null) {
if (!Template.instance().ready.get()) {
return 'btn-loading';
}
}
},
hasMore() {
if (isSetNotNull(() => Template.instance().limit)) {
if (Template.instance().limit != null) {
if (typeof Template.instance().customemoji === 'function') {
return Template.instance().limit.get() === Template.instance().customemoji().length;
}
Expand Down Expand Up @@ -61,13 +61,13 @@ Template.adminEmoji.onCreated(function() {
});

this.autorun(function() {
const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0;
const limit = (instance.limit != null) ? instance.limit.get() : 0;
const subscription = instance.subscribe('fullEmojiData', '', limit);
instance.ready.set(subscription.ready());
});

this.customemoji = function() {
const filter = (isSetNotNull(() => instance.filter))? _.trim(instance.filter.get()) : '';
const filter = (instance.filter != null) ? _.trim(instance.filter.get()) : '';

let query = {};

Expand All @@ -76,7 +76,7 @@ Template.adminEmoji.onCreated(function() {
query = { $or: [ { name: filterReg }, {aliases: filterReg } ] };
}

const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0;
const limit = (instance.limit != null) ? instance.limit.get() : 0;

return RocketChat.models.EmojiCustom.find(query, { limit: limit, sort: { name: 1 }}).fetch();
};
Expand Down
12 changes: 6 additions & 6 deletions packages/rocketchat-emoji-custom/admin/emojiEdit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toastr from 'toastr';
/* globals isSetNotNull */

Template.emojiEdit.helpers({
emoji() {
return Template.instance().emoji;
Expand All @@ -25,10 +25,10 @@ Template.emojiEdit.events({
},

'change input[type=file]'(ev) {
const e = (isSetNotNull(() => ev.originalEvent)) ? ev.originalEvent : ev;
const e = ev.originalEvent != null ? ev.originalEvent : ev;
let files = e.target.files;
if (!isSetNotNull(() => e.target.files) || files.length === 0) {
if (isSetNotNull(() => e.dataTransfer.files)) {
if (files == null || files.length === 0) {
if (e.dataTransfer != null && e.dataTransfer.files != null) {
files = e.dataTransfer.files;
} else {
files = [];
Expand All @@ -45,7 +45,7 @@ Template.emojiEdit.events({
});

Template.emojiEdit.onCreated(function() {
if (isSetNotNull(() => this.data)) {
if (this.data != null) {
this.emoji = this.data.emoji;
} else {
this.emoji = undefined;
Expand All @@ -63,7 +63,7 @@ Template.emojiEdit.onCreated(function() {

this.getEmojiData = () => {
const emojiData = {};
if (isSetNotNull(() => this.emoji)) {
if (this.emoji != null) {
emojiData._id = this.emoji._id;
emojiData.previousName = this.emoji.name;
emojiData.extension = this.emoji.extension;
Expand Down
13 changes: 6 additions & 7 deletions packages/rocketchat-emoji-custom/admin/emojiInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* globals isSetNotNull */
Template.emojiInfo.helpers({
name() {
const emoji = Template.instance().emoji.get();
Expand Down Expand Up @@ -26,9 +25,9 @@ Template.emojiInfo.helpers({
back(name) {
instance.editingEmoji.set();

if (isSetNotNull(() => name)) {
if (name != null) {
const emoji = instance.emoji.get();
if (isSetNotNull(() => emoji.name) && emoji.name !== name) {
if (emoji != null && emoji.name != null && emoji.name !== name) {
return instance.loadedName.set(name);
}
}
Expand All @@ -46,7 +45,7 @@ Template.emojiInfo.events({
e.stopPropagation();
e.preventDefault();
const emoji = instance.emoji.get();
if (isSetNotNull(() => emoji)) {
if (emoji != null) {
const _id = emoji._id;
swal({
title: t('Are_you_sure'),
Expand Down Expand Up @@ -100,17 +99,17 @@ Template.emojiInfo.onCreated(function() {

this.autorun(() => {
const data = Template.currentData();
if (isSetNotNull(() => data.clear)) {
if (data != null && data.clear != null) {
this.clear = data.clear;
}
});

this.autorun(() => {
const data = Template.currentData();
const emoji = this.emoji.get();
if (isSetNotNull(() => emoji.name)) {
if (emoji != null && emoji.name != null) {
this.loadedName.set(emoji.name);
} else if (isSetNotNull(() => data.name)) {
} else if (data != null && data.name != null) {
this.loadedName.set(data.name);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals isSetNotNull, RocketChatFileEmojiCustomInstance */
/* globals RocketChatFileEmojiCustomInstance */
Meteor.methods({
deleteEmojiCustom(emojiID) {
let emoji = null;
Expand All @@ -9,7 +9,7 @@ Meteor.methods({
throw new Meteor.Error('not_authorized');
}

if (!isSetNotNull(() => emoji)) {
if (emoji == null) {
throw new Meteor.Error('Custom_Emoji_Error_Invalid_Emoji', 'Invalid emoji', { method: 'deleteEmojiCustom' });
}

Expand Down
Loading

0 comments on commit e1c4214

Please sign in to comment.