Merge pull request #4997 from RocketChat/prevent-errors-on-logout

Prevent errors related to user status on logout
pull/5002/head
Gabriel Engel 10 years ago committed by GitHub
commit 5aaae4bd0c
  1. 8
      client/startup/startup.coffee
  2. 8
      packages/rocketchat-livechat/client/views/sideNav/livechat.js

@ -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)
)

@ -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');

Loading…
Cancel
Save