From b26a3f0e55e48acbbfb790728db696ff1bd514e5 Mon Sep 17 00:00:00 2001 From: deanoemcke Date: Sun, 7 Jun 2020 01:15:39 +1200 Subject: [PATCH 1/2] Remove update tab popup --- src/js/gsSession.js | 30 +++-------------- src/js/update.js | 82 --------------------------------------------- src/update.html | 42 ----------------------- 3 files changed, 4 insertions(+), 150 deletions(-) delete mode 100644 src/js/update.js delete mode 100755 src/update.html diff --git a/src/js/gsSession.js b/src/js/gsSession.js index e05cf34a..912295ae 100644 --- a/src/js/gsSession.js +++ b/src/js/gsSession.js @@ -5,7 +5,6 @@ var gsSession = (function() { const tabsToRestorePerSecond = 12; - let updateUrl; let updatedUrl; let initialisationMode = true; @@ -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 @@ -34,7 +32,6 @@ var gsSession = (function() { //remove any update screens await Promise.all([ - gsUtils.removeTabsByUrlAsPromised(updateUrl), gsUtils.removeTabsByUrlAsPromised(updatedUrl), ]); @@ -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 } } @@ -304,7 +299,6 @@ var gsSession = (function() { } } - await gsUtils.removeTabsByUrlAsPromised(updateUrl); await gsUtils.removeTabsByUrlAsPromised(updatedUrl); await gsIndexedDb.performMigration(lastVersion); @@ -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, @@ -834,6 +813,5 @@ var gsSession = (function() { prepareForUpdate, getUpdateType, updateSessionMetrics, - unsuspendActiveTabInEachWindow, }; })(); diff --git a/src/js/update.js b/src/js/update.js deleted file mode 100644 index ce29d487..00000000 --- a/src/js/update.js +++ /dev/null @@ -1,82 +0,0 @@ -/*global chrome, historyUtils, gsSession, gsIndexedDb, gsUtils */ -(function(global) { - 'use strict'; - - try { - chrome.extension.getBackgroundPage().tgs.setViewGlobals(global); - } catch (e) { - window.setTimeout(() => window.location.reload(), 1000); - return; - } - - function setRestartExtensionClickHandler(warnFirst) { - document.getElementById('restartExtensionBtn').onclick = async function(e) { - // var result = true; - // if (warnFirst) { - // result = window.confirm(chrome.i18n.getMessage('js_update_confirm')); - // } - // if (result) { - - document.getElementById('restartExtensionBtn').className += ' btnDisabled'; - document.getElementById('restartExtensionBtn').onclick = null; - - const currentSession = await gsSession.buildCurrentSession(); - if (currentSession) { - var currentVersion = chrome.runtime.getManifest().version; - await gsIndexedDb.createOrUpdateSessionRestorePoint( - currentSession, - currentVersion - ); - } - - //ensure we don't leave any windows with no unsuspended tabs - await gsSession.unsuspendActiveTabInEachWindow(); - - //update current session to ensure the new tab ids are saved before - //we restart the extension - await gsSession.updateCurrentSession(); - - chrome.runtime.reload(); - // } - }; - } - - function setExportBackupClickHandler() { - document.getElementById('exportBackupBtn').onclick = async function(e) { - const currentSession = await gsSession.buildCurrentSession(); - historyUtils.exportSession(currentSession, function() { - document.getElementById('exportBackupBtn').style.display = 'none'; - setRestartExtensionClickHandler(false); - }); - }; - } - - function setSessionManagerClickHandler() { - document.getElementById('sessionManagerLink').onclick = function(e) { - e.preventDefault(); - chrome.tabs.create({ url: chrome.extension.getURL('history.html') }); - setRestartExtensionClickHandler(false); - }; - } - - gsUtils.documentReadyAndLocalisedAsPromsied(document).then(function() { - setSessionManagerClickHandler(); - setRestartExtensionClickHandler(true); - setExportBackupClickHandler(); - - var currentVersion = chrome.runtime.getManifest().version; - gsIndexedDb - .fetchSessionRestorePoint(currentVersion) - .then(function(sessionRestorePoint) { - if (!sessionRestorePoint) { - gsUtils.warning( - 'update', - 'Couldnt find session restore point. Something has gone horribly wrong!!' - ); - document.getElementById('noBackupInfo').style.display = 'block'; - document.getElementById('backupInfo').style.display = 'none'; - document.getElementById('exportBackupBtn').style.display = 'none'; - } - }); - }); -})(this); diff --git a/src/update.html b/src/update.html deleted file mode 100755 index 04509078..00000000 --- a/src/update.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - -
- - - -
-

- - -

-
-

-
-
-

- -

-
-
-
- - -
-
- -
- - - - \ No newline at end of file From 5f26157f2d0621335b841f36d4d65f4765f99a72 Mon Sep 17 00:00:00 2001 From: deanoemcke Date: Tue, 16 Jun 2020 20:35:32 +1200 Subject: [PATCH 2/2] version bump --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index 4b476be0..b67571e7 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -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",