KartikTalwar / gmail-chrome-extension-boilerplate

Hello world chrome extension using gmail.js
MIT License
160 stars 62 forks source link

Randomly gmail.observe not firing #11

Open itsazzad opened 8 years ago

itsazzad commented 8 years ago

view_email, refresh, etc are not firing occasionally if the console is not open. In that case it can get the email address here: https://github.com/KartikTalwar/gmail-chrome-extension-boilerplate/blob/5c18c26bb83d8abf96c90e170f6ba67632fe4b03/main.js#L17 but after that I have put all other observers which are not firing... But if I refresh the page then its firing.

KartikTalwar commented 8 years ago

hey @itsazzad would it be possible to get the steps you are following to reproduce it? When I try it on my browser, it works fine.

itsazzad commented 8 years ago

Here is the code I use. The point is that it works always except in a very few random occasions. I am not sure about the occasion. Do you have any idea that how can it can get the email address but not starting the observers? Here it will get the email address and if it not match then will alert me and after that always should have starting the observers like as refresh or http_event but seldom its not either starting the observers because I am not getting anything in the log...

var main = function() {
  gmail = new Gmail();
  console.log('Hello,', gmail.get.user_email());
  var acceptable_emails = [ "example1@gmail.com", "example2@gmail.com" ];
  if (jQuery.inArray(gmail.get.user_email(), acceptable_emails) >= 0) {
  } else {
    alert('Sorry! Your email is not associated with this system.');
    return false;
  }

  gmail.observe.on("refresh", function(url, body, data, xhr) {
    console.log("gmail.observe.on:refresh- url:", url, 'body', body, 'data', data, 'xhr', xhr);
  });

  gmail.observe.on("http_event", function(params) {
    console.log("gmail.observe.on:http_event- url data:", params);
  });
}
refresh(main);