wearerequired / harvest-chrome

Harvest Chrome extension with Helpscout support
https://chrome.google.com/webstore/detail/required-time-tracker-for/molohbmpdeahlajdfnjppdlbbbgbbgca
Other
1 stars 2 forks source link

Add icon when the conversation is loaded via JS #4

Closed grappler closed 7 years ago

grappler commented 7 years ago

When you are in a mailbox e.g. https://secure.helpscout.net/mailbox/f5eb78b53f1e4ae3/330332/ you click on a conversation it will show without the page needing to reload. The URL is automatically updated.

At this point the icon will not show. When you refresh the page it shows.

Any ideas how to solve this and where to add the code?

ocean90 commented 7 years ago

You could use jQuery's .ajaxComplete() method to register a handler that checks the current page and adds the button if it's a single thread.

grappler commented 7 years ago

I need to add an event but I am not sure how. I was testing with something like:

return window.addEventListener("message", (function(_this) {
    return function(event) {
      if (event.data.helpscoutUrlChanged == null) {
        return;
      }
      return _this.addTimerIfOnIssue();
    };
})(this));