Comments (2)
You would just have to rework the publication to take a users _id as one of the parameters and then use it in place of this.userId
in the publication.
//Publish friend records with their related user records
Meteor.publish("friendsFor", function (userId, options) {
if(userId){
return this.ready();
}
options = options || {};
check(options, publicationOptionsSchema);
Meteor.publishWithRelations({
handle: this,
collection: Meteor.friends,
filter: {userId:userId, friendId:{$ne:userId}},
options:options,
mappings: [{
key: 'friendId',
collection: Meteor.users,
options:{fields:{username:true, status:true}}
}]
});
});
from socialize-friendships.
Thanks for your reply... This was the final thing I have based on ur reply..
I still haven't understood what this.ready();
does... but returning it seems to be an early exit strategy...
//Publish any user's friend records with their related user records
Meteor.publish("friendsFor", function (username, options) {
if(!username){
return this.ready();
}
options = options || {};
check(options, publicationOptionsSchema);
var user = Meteor.users.findOne({username: username});
Meteor.publishWithRelations({
handle: this,
collection: Meteor.friends,
filter: {userId:user._id, friendId:{$ne:user._id}},
options:options,
mappings: [{
key: 'friendId',
collection: Meteor.users,
options:{fields:{username:true, avatarId:true, status:true}}
}]
});
});
Thanks a lot for your prompt reply... I'll close the issue... :)
Also the router method to subscribe... if anyone needs it in the future... (The userProfile Publication I used... since I kept getting undefined methods error)
Router.route('/users/:username', {
name: 'userProfile',
template: "userProfile",
waitOn: function() {
return [Meteor.subscribe('outgoingFriendRequests'),
Meteor.subscribe('friendRequests'),
Meteor.subscribe('userProfile', this.params.username),
Meteor.subscribe('friendsFor', this.params.username)];
},
data: function() {
return {
user: Meteor.users.findOne({ username: this.params.username }),
requests: Meteor.requests.find({}),
friends: Meteor.friends.find({})
};
},
action: function() {
this.render();
}
});
and I might as well add the template code...
<template name="userProfile">
<h3>{{user.username}} profile ACCESSED BY {{currentUser.username}}</h3>
{{#if user.hasRequestFrom currentUser}}
<button class="btn btn-danger cancel">Cancel Request</button>
{{else}}
{{#if currentUser.hasRequestFrom user}}
<button class="btn btn-success accept">Confirm Request</button>
<button class="btn btn-danger deny">Deny Request</button>
{{else}}
{{#if user.isFriendsWith currentUser}}
<button class="btn btn-danger end">Unfriend</button>
{{else}}
<button class="btn btn-primary add">Add Friend</button>
{{/if}}
{{/if}}
{{/if}}
<h4>Friends</h4>
{{#each user.friendsAsUsers}}
<p>
<a href="{{pathFor 'userProfile' username=username}}">
{{username}}
</a>
</p>
{{else}}
<p>No friends.</p>
{{/each}}
</template>
from socialize-friendships.
Related Issues (20)
- Error when installing on socailize on my Meteor project HOT 4
- Access denied when trying to send a requestFriendship() HOT 2
- Accept friendship HOT 2
- Running request.deny() throws error HOT 3
- Please fix documentation error for Instance Methods
- No such function: isFriendsWith HOT 1
- Publications HOT 1
- what if: meteor remove insecure autopublish HOT 7
- Publication Wiki could use a publication for blocks
- Help making requests on the server HOT 2
- I think there's a little error on pendingRequests method HOT 7
- insert a new "seen:false" field in the request Schema HOT 3
- Is there a way to "sort" the users' friends by a field on the profile HOT 1
- Problems displaying requests in React HOT 5
- request.requester() won't work if I refresh the page. HOT 2
- TypeError: user is null meteor.js:930:11 .hasRequestFrom@http://localhost:3000/packages Socialize friendship meteor HOT 17
- Friend request to yourself HOT 3
- Wishlist HOT 1
- denied requests are still showing up in subscription HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socialize-friendships.