-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved user presence to an extra collection. Fix Invisible mode. Show …
…conversation
- Loading branch information
1 parent
abcaf05
commit ac1d4a3
Showing
11 changed files
with
168 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
Make sure logout users are redirected to the front page, always. | ||
|
||
Browse users | ||
Setting page | ||
|
||
Activities: what did one do, what can of activity can the others see. | ||
|
||
Check user security: do not allow user to change all their profile. | ||
|
||
|
||
myFriends and myOnlineFriends are redundant. Add pagination to myFriends, for the page that lists all friends. | ||
|
||
myFriends and myOnlineFriends are redundant. | ||
Move images to S3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
// All my data | ||
Meteor.subscribe('myData', function(){ | ||
Session.set('settings', Meteor.user().settings||{}); | ||
}); | ||
// My own picture. | ||
Meteor.subscribe('myPictures'); | ||
Meteor.startup(function(){ | ||
// All my data | ||
Meteor.subscribe('myData', function(){ | ||
Session.set('settings', Meteor.user().settings||{}); | ||
}); | ||
// My own picture. | ||
Meteor.subscribe('myPictures'); | ||
|
||
// Online friends widget. | ||
Meteor.subscribe('myOnlineFriends'); | ||
// Online friends widget. | ||
Meteor.subscribe('myOnlineFriends'); | ||
|
||
// The list of my friends. | ||
Meteor.subscribe('myFriendList'); | ||
// The list of my friends. | ||
Meteor.subscribe('myFriendList'); | ||
|
||
// My conversations | ||
conversationsHandle = Meteor.subscribeWithPagination('myConversations', 3); | ||
// My conversations | ||
conversationsHandle = Meteor.subscribeWithPagination('myConversations', 3); | ||
|
||
var currentConversation = function(){ | ||
return Session.get('currentConversation') || null; | ||
}; | ||
oneConversationHandle = Meteor.subscribeWithPagination('oneConversation', function(){ | ||
return Session.get('currentConversation') || null; | ||
}, Messages.messagePerPage); | ||
|
||
oneConversationHandle = Meteor.subscribeWithPagination('oneConversation', currentConversation, 4); | ||
// When visiting someone's profile | ||
Deps.autorun(function () { | ||
userProfileHandle = Meteor.subscribe("oneUserProfile", Session.get("currentUserProfile")); | ||
userPictureHandle = Meteor.subscribe("oneUserPictures", Session.get("currentUserProfile")); | ||
}); | ||
|
||
// When visiting someone's profile | ||
Deps.autorun(function () { | ||
userProfileHandle = Meteor.subscribe("oneUserProfile", Session.get("currentUserProfile")); | ||
userPictureHandle = Meteor.subscribe("oneUserPictures", Session.get("currentUserProfile")); | ||
}); | ||
// Questions for the profile form. | ||
Meteor.subscribe('questions'); | ||
|
||
// Questions for the profile form. | ||
Meteor.subscribe('questions'); | ||
Meteor.subscribe('adminShowEveryone'); | ||
|
||
Meteor.subscribe('showFuckingEveryone'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
<template name="conversation"> | ||
|
||
yoyo | ||
<ul> | ||
{{#each messages}} | ||
<li>To:{{to}}, From:{{from}}</li> | ||
{{/each}} | ||
</ul> | ||
<ul> | ||
{{#each messages}} | ||
{{> message}} | ||
{{/each}} | ||
</ul> | ||
|
||
</template> | ||
|
||
<template name="message"> | ||
<li> | ||
<p>From:{{sender}}. to:{{receiver}}, {{timestamp}}</p> | ||
<p>{{body}}</p> | ||
</li> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
Template.conversation.helpers({ | ||
messages: function(){ | ||
console.log('message'); | ||
// | ||
var conversation = Conversations.findOne(Session.get('currentConversation')); | ||
if(!conversation){ | ||
return; | ||
} | ||
|
||
return Messages.find({}, {sort: {timestamp: -1}}); | ||
return Messages.find( | ||
{ | ||
$or: [ | ||
{from: Meteor.userId(), to: conversation.with}, | ||
{to: Meteor.userId(), from: conversation.with} | ||
] | ||
}, | ||
{sort: {sent: -1}} | ||
); | ||
} | ||
}); | ||
Template.message.helpers({ | ||
timestamp: function(){ | ||
return moment(this.sent).fromNow(); | ||
}, | ||
sender: function(){ | ||
console.log(this); | ||
return this.from == Meteor.userId()? __('messages.you') : Meteor.users.findOne(this.from)['profile'].name; | ||
}, | ||
receiver: function(){ | ||
return this.to == Meteor.userId()? __('messages.you') : Meteor.users.findOne(this.to)['profile'].name; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
Template.online_friends.helpers({ | ||
friends: function(){ | ||
var friends = Meteor.user().friends || []; | ||
return Meteor.users.find({'profile.online': 1, _id: {$in: friends}}); | ||
var friends = Presences.find({}); | ||
var ids = []; | ||
friends.forEach(function(f){ | ||
ids.push(f.user); | ||
}); | ||
|
||
return Meteor.users.find({_id: {$in: ids}}, {sort:{'profile.name': 1}}); | ||
}, | ||
count: function(){ | ||
var friends = Meteor.user().friends || []; | ||
return Meteor.users.find({'profile.online': 1, _id: {$in: friends}}).count(); | ||
// Presence subscription only show online users... | ||
return Presences.find({}).count() + 1; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Presences = new Meteor.Collection('presences'); | ||
|
||
|
||
// Can't touch me | ||
Presences.deny({ | ||
insert: function(){ return true; }, | ||
update: function(){ return true; }, | ||
remove: function(){ return true; } | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.