Browse Source

this fixes #21

pull/2/head 0.8.0.0-alpha.10
gorhill 10 years ago
parent
commit
ff4d827e1f
  1. 23
      src/js/popup.js
  2. 2
      src/js/tab.js

23
src/js/popup.js

@ -71,11 +71,13 @@ var matrixHeaderPrettyNames = {
messaging.start('popup.js'); messaging.start('popup.js');
var onMessage = function(msg) { var onMessage = function(msg) {
if ( msg.what === 'urlStatsChanged' ) {
if ( matrixSnapshot.url === msg.pageURL ) {
makeMenu();
if ( msg.what !== 'urlStatsChanged' ) {
return;
} }
if ( matrixSnapshot.url !== msg.pageURL ) {
return;
} }
queryMatrixSnapshot(makeMenu);
}; };
messaging.listen(onMessage); messaging.listen(onMessage);
@ -99,8 +101,7 @@ function setUserSetting(setting, value) {
/******************************************************************************/ /******************************************************************************/
function updateMatrixSnapshot() { function updateMatrixSnapshot() {
var snapshotReady = function(response) {
matrixSnapshot = response;
var snapshotReady = function() {
updateMatrixColors(); updateMatrixColors();
updateMatrixBehavior(); updateMatrixBehavior();
updateMatrixButtons(); updateMatrixButtons();
@ -1109,10 +1110,6 @@ function dropDownMenuHide() {
// Because chrome.tabs.query() is async // Because chrome.tabs.query() is async
var onMatrixSnapshotReady = function(response) { var onMatrixSnapshotReady = function(response) {
matrixSnapshot = response;
targetTabId = response.tabId;
// Now that tabId and pageURL are set, we can build our menu // Now that tabId and pageURL are set, we can build our menu
initMenuEnvironment(); initMenuEnvironment();
makeMenu(); makeMenu();
@ -1137,6 +1134,10 @@ var queryMatrixSnapshot = function(callback) {
tabId: targetTabId, tabId: targetTabId,
tabURL: matrixSnapshot.url tabURL: matrixSnapshot.url
}; };
var snapshotReceived = function(response) {
matrixSnapshot = response;
callback();
};
var onTabsReceived = function(tabs) { var onTabsReceived = function(tabs) {
if ( tabs.length === 0 ) { if ( tabs.length === 0 ) {
return; return;
@ -1144,12 +1145,12 @@ var queryMatrixSnapshot = function(callback) {
var tab = tabs[0]; var tab = tabs[0];
request.tabId = targetTabId = tab.id; request.tabId = targetTabId = tab.id;
request.tabURL = tab.url; request.tabURL = tab.url;
messaging.ask(request, callback);
messaging.ask(request, snapshotReceived);
}; };
if ( targetTabId === undefined ) { if ( targetTabId === undefined ) {
chrome.tabs.query({ active: true, currentWindow: true }, onTabsReceived); chrome.tabs.query({ active: true, currentWindow: true }, onTabsReceived);
} else { } else {
messaging.ask(request, callback);
messaging.ask(request, snapshotReceived);
} }
}; };

2
src/js/tab.js

@ -422,7 +422,7 @@
'gcPageStats', 'gcPageStats',
null, null,
gcPageStats, gcPageStats,
5 * 60 * 1000,
(2.5 * 60 * 1000) | 0,
true true
); );
})(); })();
Loading…
Cancel
Save