I don't want to run a constant poll on the heartbeat block, it's expensive. I think it would be better (for me) if the pollling happens when users submit a new fb-style status message on the profile. This way people can see their new post.

Thanks!

Comments

Stalski’s picture

Assigned: Unassigned » Stalski
Status: Active » Closed (won't fix)

The interval for polling can be disabled for a stream at /admin/build/heartbeat/streams and choose a stream. This configuration is for each stream.

When posting a shout, it's possible for heartbeat to hook into the after event in javascript and manually call the poll for newer messages, and that works. You will have to talk to the maintainer of facebook status for a after javascript event so heartbeat fb_status block can call it after posting.

ManyNancy’s picture

Does this mean I should use shout in place of fb status for 'wall' postings?

Stalski’s picture

That's your choice. The maintainer of facebook_status said to me a couple of times that his module has lots of functionality more than shouts, so that's the factor for your decision i guess. If you use shouts, it's just a small post you can do to the stream. (no twitter behaviour)
For the facebook status update stream thing , it's currently not possible to hook into the afterStatusUpdate process of fb_status. I think you can ask him (IceCreamYou) and it's not that hard to implement such a callback. (Flag does it for instance)

ManyNancy’s picture

OK, the issue is here: #735326: Javascript Event for submission success.

Thanks.

Stalski’s picture

Status: Closed (won't fix) » Closed (fixed)

ok subscribed myself to it :)

ManyNancy’s picture

Status: Closed (fixed) » Active

The latest version of fbstatus has the event.

Stalski’s picture

Status: Active » Closed (fixed)

cool :)
Then why do you reopen this ticket? It's you who can fix this in your custom glue module. Heartbeat can never supply this in the module ofcourse.
Just do like the shout module and call the poll for newer messages in the fb_status callback.

regards stalski

icecreamyou’s picture

Updating a Heartbeat view when a Facebook-style Status is submitted can be done in one of several ways.

  • Use the FBSS interface to attach a view to the status update box. This requires no custom code but the view must be shown directly beneath the status update box.
  • Implement hook_facebook_status_refresh_selectors() in a custom module. As custom coding goes, this is very easy. It uses FBSS' update mechanism instead of Heartbeat's. However, the responsiveness of the updating will be slower.
  • Change facebook_status.js to add the following code between lines 63 and 64 in the latest dev:
    if (Drupal.heartbeat) {
      Drupal.heartbeat.pollMessages();
    }
    

    Assuming this works (I haven't actually tried it) I think it may be a good idea to just add this to FBSS itself.

  • Write a custom module that includes a JavaScript file (use hook_form_alter() to only include this JS where you need it) with this code:
    Drupal.behaviors.myModule = function (context) {
      if (context == document) {
        context = $(document);
      }
      context.find('#facebook_status_replace').bind('ahah_success', function(context) {
        if ($(context.target).html() != $(this).html()) {
          return;
        }
        if (Drupal.heartbeat) {
          Drupal.heartbeat.pollMessages();
        }
      });
    }
    

    I'm about 90% sure this option works.

Stalski’s picture

Hey,

thx and you are correct about the approaches you suggest.
In my opinion, the best option is a direct approach like possibility 3, however without the hard-coded link to another module (heartbeat). So what you could do for all contributed modules is the flag-approach. You provide javascript-hooks to do something custom "before fbss is submit" and "after fbss is submit".

Approach Four will work as well and you can indeed use the behaviors in your module. (In heartbeat i could not so that since poll messages would have to reattach behavior, adding the polling behavior again (and again and again untill js-crash).

I will try out all approaches at my demo site and implement (+ document) the best approach that i see (this will probably be the one with the smallest load).

thx again :)

icecreamyou’s picture

FBSS does allow using JavaScript events for "before" and "after" status submission as well as clicking the "Refresh" link if that is enabled. (The "click" event is enough for "before," and "ahah_success" is invoked "after.")

I don't mind hard-coding Heartbeat integration since it's only 3 lines, as long as everything still works whether Heartbeat is installed or not. I will look forward to hearing from you which approach works best before I do anything though. Thanks for being willing to test!

Stalski’s picture

Status: Closed (fixed) » Needs review
JJacobo’s picture

Was this ever hardcoded?

icecreamyou’s picture

You mean in the two weeks since it was proposed and not marked fixed? No. As I said above,

I don't mind hard-coding Heartbeat integration since it's only 3 lines, as long as everything still works whether Heartbeat is installed or not. I will look forward to hearing from [Stalski] which approach works best before I do anything though.

Since this issue hasn't been updated since then, I haven't heard anything, so I haven't hard-coded any of the solutions proposed above. When I have, this issue will be updated and it will appear in the CVS commit log.

JJacobo’s picture

You're a bit touchy, no? I don't think that sarcasm was necessary there.

I was just asking because we're trying to get this to work.

icecreamyou’s picture

I apologize.

icecreamyou’s picture

Status: Needs review » Fixed

I committed option #3 to FBSS dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.