After click to see new posts



I have shown this feature in meteor forums. When your forum all posts page is open for sometime during that time some new posts has came then it will not display directly there is one link that state “Click to see 3 new post”. I want to implement this same feature in my application that i don’t want to display new added post but when user is browsing my application and new posts will come there is one link to that new posts please click to see that post. Please give me idea that how can i implement this feature. I am using masonry to display my posts. please help


There’s a simple method to achieve what you want. Instead of showing all posts, show only the posts with createdAt lower than the time variable that tells you when user checked messages for the last time. Then provide a counter of messages with createAt higher than that, so the user knows how many new message there are. When user changes his view or clicks on hidden messages button, simply update the time variable.


so i need to store current time when user refresh the page. I think its not good solution because its extra call on every page refresh.


If you don’t want to store time in a reactive variable, I can’t really help you. All the alternatives that I can think of require storing things too. Forum scripts store such things anyways f.e. to know when the user was active last time etc.

Good luck and please share the algorithm when you find solution.


i can store time but if i store time in session then i need to store it at client side and it takes client pc’s time not server time


Froom server side there is no change.

On client we have some session or reacive variable lets say lastRefresh

in helper which shows posts you just do

Posts.find ({
  updateTime: {
    $lte: lastRefresh.get()

And than new post count

Posts.find ({
  updateTime: {
    $gt: lastRefresh.get()


I have implemented same thing below is my code

Template.posts.onCreated(function () {
        Session.set("currentTime", new Date());

Template.posts.onRendered(function () {
    posts.find({createdAt: {$gt: Session.get("currentTime")}}).observeChanges({
        added: function (id, doc) {
            setTimeout(function () {
                console.log($("[data-id='" + id + "']"));
                $("[data-id='" + id + "']").hide();
                setTimeout(function () {
                }, 10)

            }, 10)



@shock can you help?


help how? :smiley:

asdfgh qwerty


any example implement this kind of feature


I did not implemented it anywhere yet, just posted which way seems best to me.
And I think you dont need .observe as Cursor.count() is probably reactive (it is not directly mentioned in

Just divide it to 2 templates or divs or whatever
1 showing the “old” list
and the 2nd just showing count of new posts if it is greater than 0