Skip to content

Commit

Permalink
Fixed bug where automatic unsuspension would cause a tab to reload af…
Browse files Browse the repository at this point in the history
…ter closing a tab next to it #114
  • Loading branch information
deanoemcke committed Nov 13, 2015
1 parent e762b1e commit aa12f59
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var tgs = (function () {
lastStatus = 'normal',
notice = {},
contextMenuItems = false,
unsuspendRequestList = {};
unsuspendRequestList = {},
lastTabCloseTimestamp = new Date();


//set gloabl sessionId
Expand Down Expand Up @@ -400,6 +401,13 @@ var tgs = (function () {
updateIcon(info.status);
});

//check to see if we have just recently removed a tab
//if so, assume this is an 'accidental' tab focus and do not unsuspend
if (lastTabCloseTimestamp > (new Date()) - 500) {
if (debug) console.log('ignoring tab focus');
return;
}

//pause for a bit before assuming we're on a new tab as some users
//will key through intermediate tabs to get to the one they want.
(function () {
Expand Down Expand Up @@ -1005,6 +1013,7 @@ var tgs = (function () {
if (unsuspendRequestList[tabId]) {
delete unsuspendRequestList[tabId];
}
lastTabCloseTimestamp = new Date();
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
//only save session if the tab url has changed
Expand Down

0 comments on commit aa12f59

Please sign in to comment.