Weird critical bug when opening translate page
So I'm getting a really weird bug. If I have my app open in one tab and then open another tab going to the message format translate page. I run into a number of errors and issues. For example I lost data and get Type Error.
This only happens if I open the translate page. Attached screenshots to better explain.
When the translate page is open

Here is the translate page

When the translate page is closed (but I have to close and open the tab / app)

And this is the error I'm getting
Exception in template helper: TypeError: Cannot read property 'userId' of undefined
at Object.Template.organization.helpers.ownsOrganization (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:431:96)
at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:28387
at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:16297
at Object.l.call (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:123:1819)
at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:285:10424
at null.
I don't see anything messageformat specific in the error. Could be a problem with subscriptions and reactivity. Can you show me the code for the Template.organization ownsOrganization helper?
@gadicc I also thought it was not related to message format but it only happens when I open the translate page.
It's a simple check var noOrganization = _.isEmpty(Meteor.user().organizationId) === true;
I think something happens with the user or allow / deny when the translate page opens
That's super weird that the translate page could affect the main meteor user subscription. But if that's your only problem, the fix is quite easy :)
var user = Meteor.user();
var noOrganization = user && _.isEmpty(user.organizationId);
The /translate route doesn't do anything user related, and the allow/deny callbacks are only checked when trying to enter a language.
Wait I just realized that's the wrong line... it's something needing .userId. Or did you past me the full function and that error is coming from inside of Meteor?
Yea it's a weird bug, as for the code here is the entire function it's inside iron-router
OrganizationController = RouteController.extend({
template: 'organization',
waitOn: function() {
if(getConnectionStatus()) {
return Meteor.subscribe('organizations');
} else {
this.render();
}
},
organization: function() {
return Organizations.findOne();
},
data: function() {
var noOrganization = _.isEmpty(Meteor.user().organizationId) === true;
return {
organization: this.organization(),
noOrganization: noOrganization
};
},
onBeforeAction: function () {
AccountsEntry.signInRequired(this);
}
});
@almogdesign I can't reproduce that in [v2]. Which version are you using?