Skip to content

Commit

Permalink
Regression: Prevent startup errors for mentions parsing (#14219)
Browse files Browse the repository at this point in the history
Sometimes `Meteor.user()` is falsy even with `Meteor.userId()` defined.
  • Loading branch information
tassoevan authored and ggazzo committed Apr 22, 2019
1 parent 9d211f3 commit b8c0e6f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/mentions/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { callbacks } from '../../callbacks';
import { settings } from '../../settings';
import { Users } from '../../models/client';
import { MentionsParser } from '../lib/MentionsParser';

let me;
let useRealName;
let pattern;

Meteor.startup(() => Tracker.autorun(() => {
me = Meteor.userId() && Meteor.user().username;
const uid = Meteor.userId();
me = uid && (Users.findOne(uid, { fields: { username: 1 } }) || {}).username;
pattern = settings.get('UTF8_Names_Validation');
useRealName = settings.get('UI_Use_Real_Name');
}));
Expand Down

0 comments on commit b8c0e6f

Please sign in to comment.