Skip to content

Commit

Permalink
Merge pull request greatsuspender#1167 from greatsuspender/1147-remov…
Browse files Browse the repository at this point in the history
…e-update-popup

Defer updates if tabs are suspended
  • Loading branch information
deanoemcke authored Jun 16, 2020
2 parents 9730c09 + 5f26157 commit 394dcfd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 151 deletions.
30 changes: 4 additions & 26 deletions src/js/gsSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var gsSession = (function() {

const tabsToRestorePerSecond = 12;

let updateUrl;
let updatedUrl;

let initialisationMode = true;
Expand All @@ -21,7 +20,6 @@ var gsSession = (function() {
let syncedSettingsOnInit;

async function initAsPromised() {
updateUrl = chrome.extension.getURL('update.html');
updatedUrl = chrome.extension.getURL('updated.html');

// Set fileUrlsAccessAllowed to determine if extension can work on file:// URLs
Expand All @@ -34,7 +32,6 @@ var gsSession = (function() {

//remove any update screens
await Promise.all([
gsUtils.removeTabsByUrlAsPromised(updateUrl),
gsUtils.removeTabsByUrlAsPromised(updatedUrl),
]);

Expand Down Expand Up @@ -64,14 +61,12 @@ var gsSession = (function() {
}

const suspendedTabCount = await gsUtils.getSuspendedTabCount();
if (!sessionRestorePoint || suspendedTabCount > 0) {
//show update screen
await gsChrome.tabsCreate(updateUrl);
//ensure we don't leave any windows with no unsuspended tabs
await unsuspendActiveTabInEachWindow();
} else {
if (suspendedTabCount === 0) {
// if there are no suspended tabs then simply install the update immediately
chrome.runtime.reload();
} else {
//do nothing. this prevents chrome from automatically updating and will instead wait
//until a browser restart to update
}
}

Expand Down Expand Up @@ -304,7 +299,6 @@ var gsSession = (function() {
}
}

await gsUtils.removeTabsByUrlAsPromised(updateUrl);
await gsUtils.removeTabsByUrlAsPromised(updatedUrl);

await gsIndexedDb.performMigration(lastVersion);
Expand Down Expand Up @@ -799,21 +793,6 @@ var gsSession = (function() {
return sessionMetrics;
}

async function unsuspendActiveTabInEachWindow() {
const activeTabs = await gsChrome.tabsQuery({ active: true });
const suspendedActiveTabs = activeTabs.filter(tab =>
gsUtils.isSuspendedTab(tab)
);
if (suspendedActiveTabs.length === 0) {
return;
}
for (let suspendedActiveTab of suspendedActiveTabs) {
tgs.unsuspendTab(suspendedActiveTab);
}
await gsUtils.setTimeout(1000);
await unsuspendActiveTabInEachWindow();
}

return {
initAsPromised,
runStartupChecks,
Expand All @@ -834,6 +813,5 @@ var gsSession = (function() {
prepareForUpdate,
getUpdateType,
updateSessionMetrics,
unsuspendActiveTabInEachWindow,
};
})();
82 changes: 0 additions & 82 deletions src/js/update.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_ext_extension_name__",
"description": "__MSG_ext_extension_description__",
"version": "7.1.6",
"version": "7.1.7",
"default_locale": "en",
"permissions": [
"tabs",
Expand Down
42 changes: 0 additions & 42 deletions src/update.html

This file was deleted.

0 comments on commit 394dcfd

Please sign in to comment.