Having trouble getting socialize:messaging working with React Native

Newbie to Meteor/React Native and have been enjoying the super fast development so far, but seem to have run into my first speed bump. More like I’m stuck in a ditch and could really use some help. :frowning: @spencercarli @copleykj

class Inbox extends Component {
    constructor(props) {
        super();
    }
    renderRow(message) {
        return (
            <Text>{message.body}</Text>
        );
    }
    render() {
        return (
                <MeteorListView
                    collection="messages"
                    renderRow={this.renderRow}
                />
        );
    }
}

export default createContainer(params => {
    Meteor.subscribe('messages');
    return {};
}, Inbox);

Now, I’m assuming I need to make a publication that returns the messages of the conversations that the currently logged in user is participating in?

https://atmospherejs.com/socialize/messaging

export default () => {
    Meteor.publish('messages', function () {

       var conversations = Meteor.conversations.find({_participants: this.userId});//better way to get conversations for the current user?
        // now i don't know what to do!!

        conversations.forEach(function(c) {
            c.messages(/*optional params*/).forEach(function(message){
	        console.log(message.user().username, ": ", message.body);
            });
        });
// the above seems to get me the information I need
// but I don't know how to do it through a cursor so I can publish it to the client.
// need an ELI5 example
});
}

I appreciate it. Thank you so much for your time.

1 Like

Have you tried the github wiki? Example publications are given there which should get you going. https://github.com/copleykj/socialize-messaging/wiki/Publications

2 Likes

@copleykj Unbelievable response time from the creator himself!! :heart_eyes:

I didn’t, in fact. From now on I will remember to check wiki pages. Meteor.publishWithRelations seems to be just what I needed, after I’d been pretty much stuck all day on this. I’ll give it a shot.

Thank you so much.

1 Like

You are very welcome. Let me know if you need any further help.

1 Like

Copy pasted the first wiki example in and it works perfectly. Going to have to check out the other libraries you mentioned: aldeed:simple-schema, tmeasday:publish-with-relations, meteorhacks:unblock. Didn’t know they existed. :stuck_out_tongue: Thanks again.

1 Like