inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

The user subscription is not being merged to the default user data from Meteor #269

Closed rj-david closed 7 years ago

rj-david commented 7 years ago

I'm using a custom subscription to fetch custom fields in my users table. In my normal Meteor app, when I subscribed to the record of the current user, the data was automatically merged to the user data in Meteor.user()

I'm not getting the same behavior using react-native-meteor.

My subscription code (don't mind the security checks, I confirmed they were working):

console.log(Meteor.user());

const handle = Meteor.subscribe('currentUser', secureInputs({}));
console.log(Meteor.user());

const user = Meteor.collection('users').findOne({});
console.log(user);

console.log() gave the same results

My publication code:

// publish logged in user data
Meteor.publish('currentUser', function(inputs) {
    if (securityCheck(inputs.token, inputs.seed)) {
        if (this.userId) {
            const result = Meteor.users.find({ _id: this.userId }, {
                fields: {
                    _id: 1,
                    'services.mobile.id': 1,
                    email: 1,
                    active: 1,
                    suspended: 1,
                    roles: 1

                }
            });

            return result;
        }
    }

    this.ready();
});