From 32f2263be980804e79d5461366d5d7417979a7bd Mon Sep 17 00:00:00 2001 From: victor <14vic04!> Date: Wed, 5 Sep 2018 16:56:27 +0300 Subject: [PATCH] fixes --- .../client/views/app/tabbar/visitorInfo.js | 8 ++++---- .../client/views/sideNav/livechat.js | 10 +++++----- .../rocketchat-livechat/server/methods/closeInquiry.js | 4 ++-- .../rocketchat-livechat/server/methods/getInquiries.js | 2 +- .../server/models/LivechatInquiry.js | 2 +- .../server/publications/livechatInquiries.js | 6 ++---- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/rocketchat-livechat/client/views/app/tabbar/visitorInfo.js b/packages/rocketchat-livechat/client/views/app/tabbar/visitorInfo.js index 43e694c91ec0..b2fa5719b8df 100644 --- a/packages/rocketchat-livechat/client/views/app/tabbar/visitorInfo.js +++ b/packages/rocketchat-livechat/client/views/app/tabbar/visitorInfo.js @@ -243,7 +243,7 @@ Template.visitorInfo.events({ 'click .archive-room'(event) { event.preventDefault(); - Meteor.call('archiveRoom', this.rid, function(error/*, result*/) { + Meteor.call('archiveRoom', this.rid, function(error) { if (error) { console.log(error); } else { @@ -289,13 +289,13 @@ Template.visitorInfo.onCreated(function() { } this.autorun(() => { - this.user.set(LivechatVisitor.findOne({ '_id': this.visitorId.get() })); + this.user.set(LivechatVisitor.findOne({ _id: this.visitorId.get() })); - //load guest department + // load guest department if (this.user.get() && this.user.get().department) { const sub = this.subscribe('livechat:departments', this.user.get().department); if (sub.ready()) { - const department = LivechatDepartment.findOne({_id: this.user.get().department}); + const department = LivechatDepartment.findOne({ _id: this.user.get().department }); if (department) { this.department.set(department); } diff --git a/packages/rocketchat-livechat/client/views/sideNav/livechat.js b/packages/rocketchat-livechat/client/views/sideNav/livechat.js index e7d25b3cc7ac..7cc1558cb0d1 100644 --- a/packages/rocketchat-livechat/client/views/sideNav/livechat.js +++ b/packages/rocketchat-livechat/client/views/sideNav/livechat.js @@ -36,16 +36,16 @@ Template.livechat.helpers({ }, inquiries() { - //load all livechatDepartmentAgents fpr current agent + // load all livechatDepartmentAgents fpr current agent const departmentAgents = LivechatDepartmentAgents.find({ - agentId : Meteor.userId() + agentId : Meteor.userId(), }); const departmentIds = []; departmentAgents.forEach((agent) => { departmentIds.push(agent.departmentId); }); - //also include inquiries without a department + // also include inquiries without a department if (departmentIds.length) { departmentIds.push(null); departmentIds.push(''); @@ -54,7 +54,7 @@ Template.livechat.helpers({ // get all inquiries of the department const inqs = LivechatInquiry.find({ department: { - $in: departmentIds + $in: departmentIds, }, status: 'open', }, { @@ -148,6 +148,6 @@ Template.livechat.onCreated(function() { } }); - this.subscribe('livechat:inquiry', {status: 'open'}); + this.subscribe('livechat:inquiry', { status: 'open' }); this.subscribe('livechat:departmentAgents', null); }); diff --git a/packages/rocketchat-livechat/server/methods/closeInquiry.js b/packages/rocketchat-livechat/server/methods/closeInquiry.js index 893d1dc99f7a..5529405d27c7 100644 --- a/packages/rocketchat-livechat/server/methods/closeInquiry.js +++ b/packages/rocketchat-livechat/server/methods/closeInquiry.js @@ -5,9 +5,9 @@ Meteor.methods({ } // find inquiry corresponding to room - const inquiry = RocketChat.models.LivechatInquiry.findOne({rid}); + const inquiry = RocketChat.models.LivechatInquiry.findOne({ rid }); // mark inquiry as open return RocketChat.models.LivechatInquiry.closeInquiry(inquiry._id); - } + }, }); diff --git a/packages/rocketchat-livechat/server/methods/getInquiries.js b/packages/rocketchat-livechat/server/methods/getInquiries.js index 40d3017dda05..55d231e4035e 100644 --- a/packages/rocketchat-livechat/server/methods/getInquiries.js +++ b/packages/rocketchat-livechat/server/methods/getInquiries.js @@ -5,5 +5,5 @@ Meteor.methods({ } return RocketChat.models.LivechatInquiry.find(filter || {}).fetch(); - } + }, }); diff --git a/packages/rocketchat-livechat/server/models/LivechatInquiry.js b/packages/rocketchat-livechat/server/models/LivechatInquiry.js index f225d7b7e687..eb1a36c02599 100644 --- a/packages/rocketchat-livechat/server/models/LivechatInquiry.js +++ b/packages/rocketchat-livechat/server/models/LivechatInquiry.js @@ -58,7 +58,7 @@ class LivechatInquiry extends RocketChat.models._Base { */ closeInquiry(inquiryId) { this.update({ - '_id': inquiryId + _id: inquiryId, }, { $set: { status: 'closed' }, }); diff --git a/packages/rocketchat-livechat/server/publications/livechatInquiries.js b/packages/rocketchat-livechat/server/publications/livechatInquiries.js index 83709f225413..320f291c76f2 100644 --- a/packages/rocketchat-livechat/server/publications/livechatInquiries.js +++ b/packages/rocketchat-livechat/server/publications/livechatInquiries.js @@ -1,4 +1,4 @@ -Meteor.publish('livechat:inquiry', function() { +Meteor.publish('livechat:inquiry', function(query) { if (!this.userId) { return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:inquiry' })); } @@ -7,7 +7,5 @@ Meteor.publish('livechat:inquiry', function() { return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:inquiry' })); } - query = query || {}; - - return RocketChat.models.LivechatInquiry.find(query); + return RocketChat.models.LivechatInquiry.find(query || {}); });