1

Note - Using SharePoint 2013 social functionality (not Yammer).

It has been reported (and confirmed) by my Mac users that when they have a browser (confirmed for Chrome and Safari) hidden in the background for a period of time and then bring it back up later, the newsfeed notices (the number in parentheses that shows how many new items exist that are not currently displayed) does not update until either mousing into the newsfeed web part or reloading the page.

Does anyone have insight on how to fix this so that the number is updated without action by the end-user? Additionally, does anyone know what JavaScript is called to actually update the newsfeed number? I'm having trouble trying to decipher the .js files to figure it out. Thanks.

1
  • Clarification - on reload, it just shows the new items, not the number of new items after Following or Mentions.
    – Todd
    May 12, 2014 at 20:31

1 Answer 1

1

OK, here's how I made it work. Other suggestions are still welcome, but I wanted to put this in here for anyone else dealing with this issue.

I added a feature in my SharePoint farm that uses the AdditionalPageHead Delegate Control to insert additional JavaScript to every page. In that control, I've added a reference to jQuery (see my answer in How to upload jQuery library into web parts without master page for more information) as well as another JavaScript file that contains the following code:

$(window).on("blur focus", function (e) {
var prevType = $(this).data("prevType");

if (prevType != e.type) {   //  reduce double fire issues
    switch (e.type) {
        case "blur":
            // do work
            break;
        case "focus":
            // do work
            FireEvent("ms-newsfeedpartdiv", "mouseover");
            break;
    }
}

$(this).data("prevType", e.type);
})

function FireEvent(ElementId, EventName)
{
    if (document.getElementById(ElementId) != null)
    {
        if (document.getElementById(ElementId).fireEvent)
        {
            document.getElementById(ElementId).fireEvent('on' + EventName);
        }
        else
        {
            var evObj = document.createEvent('Events');
            evObj.initEvent(EventName, true, false);
            document.getElementById(ElementId).dispatchEvent(evObj);
        }
    }
}

The first part is a jQuery block that detects when the browser gains focus and runs the second block, a function that simulates a mouseover event for the newsfeed web part (which forces it to update).

It's a hack, but it seems to be working in my test environment very well.

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.