diff --git a/client/startup/startup.coffee b/client/startup/startup.coffee index 6e3bb251b93..316d533f7ac 100644 --- a/client/startup/startup.coffee +++ b/client/startup/startup.coffee @@ -59,7 +59,9 @@ Meteor.startup -> status = undefined Tracker.autorun -> - if Meteor.user()?.status isnt status - status = Meteor.user().status - fireGlobalEvent('status-changed', status) + return if not Meteor.userId() + + if Meteor.user()?.status isnt status + status = Meteor.user().status + fireGlobalEvent('status-changed', status) ) diff --git a/packages/rocketchat-livechat/client/views/sideNav/livechat.js b/packages/rocketchat-livechat/client/views/sideNav/livechat.js index 8dc82cd55b3..94586f60f6a 100644 --- a/packages/rocketchat-livechat/client/views/sideNav/livechat.js +++ b/packages/rocketchat-livechat/client/views/sideNav/livechat.js @@ -126,8 +126,12 @@ Template.livechat.onCreated(function() { this.statusLivechat = new ReactiveVar(); this.autorun(() => { - const user = RocketChat.models.Users.findOne(Meteor.userId(), { fields: { statusLivechat: 1 } }); - this.statusLivechat.set(user.statusLivechat); + if (Meteor.userId()) { + const user = RocketChat.models.Users.findOne(Meteor.userId(), { fields: { statusLivechat: 1 } }); + this.statusLivechat.set(user.statusLivechat); + } else { + this.statusLivechat.set(); + } }); this.subscribe('livechat:inquiry');