0

I have a Facebook style news feed view which updates via node.js and rules when new content is created. This all works fine however if one user is in the process of commenting on a node teaser (comments shown on node teasers on the view) and another user creates a new node, the view then updates causing the unfinished comment to be lost.

My question is: is there a way to restrict the node.js view update for the current user if the view is currently active?

1 Answer 1

0

I had and just have the same problem with node.js views update. It seems that the module is refreshing every view that's in use.

I managed to get a workaround by styling my news feed with an open comment section. But i think this is only a solution when you do not expect a hughe amount of comments.

In another use case I implemented another workaround with jQuery:

On my page users can create requests and other users are able to answer these request. A request is a node type and an answer is a node type. They are connected through entity reference module and i wanted to have some sort of inbox functionality where every answer to a specific request is shown in a menu on the specific request page. A user could then click on a answer-menu-item and the whole answer is shown under the request. To give it a more chat feeling I implemented the comment form of the specific answer and styled it to look like a chat form.

This is done with two views implemented on that page. The menu functionality is done with jQuery (Click on menu item -> show related views row of second view). With node.js views refresh I managed to get the chat feeling (When a new comment is added -> refresh first and second view).

I then ran into the same issue like you described above. Each time a user submitted a new comment both views refreshed but the views returned to the their output states - for example: the user was reading an answer of user G and was commenting on that answer when the view was refreshing because of a new comment on an answer of user Y. The view returned to its output state and was not showing any answer because they were initially hidden to achieve the inbox / menu functionality.

My workaround for that problem is:

var content = [the views-row belonging to the menu entry]
$(specific-menu-item).click(function(e){
    $(".my-second-view .views-row").hide();
    $(content).show();
    Cookies.set('latest-viewed-answer', content);
    return false;
    e.preventDefault();
});

$(document).ajaxComplete(function() {
  var latest = Cookies.get('latestmessage');
  $(".my-second-view .views-row").hide();
  $(latest).show();
});

To get the Cookie thing working https://github.com/js-cookie/js-cookie

Sorry for my long answer, but i thought that it would be necessary to understand my needs to understand my workaround...

Because this is still a workaround and because I'm asking myself if there will be performance and server issues with our approaches (news feed and chat) I would love to see a solution that is really solving the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.