Skip to content

Commit

Permalink
Only show welcome screen on new profile installs (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanoemcke committed Oct 11, 2018
1 parent 1cb3842 commit e339c8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/js/gsSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var gsSession = (function() {
const updateUrl = chrome.extension.getURL('update.html');
const updatedUrl = chrome.extension.getURL('updated.html');

let initialisationMode = false;
let initialisationMode = true;
let initPeriodInSeconds;
let initTimeoutInSeconds;
let sessionId;
Expand All @@ -20,6 +20,7 @@ var gsSession = (function() {
let startupRecoveryTimeTakenInSeconds;
let startupType;
let startupLastVersion;
let syncedSettingsOnInit;

function initAsPromised() {
return new Promise(async function(resolve) {
Expand Down Expand Up @@ -126,6 +127,10 @@ var gsSession = (function() {
return updateType;
}

function setSynchedSettingsOnInit(syncedSettings) {
syncedSettingsOnInit = syncedSettings;
}

async function runStartupChecks() {
initialisationMode = true;
const currentSessionTabs = await gsChrome.tabsQuery();
Expand Down Expand Up @@ -182,9 +187,14 @@ var gsSession = (function() {
async function handleNewInstall(curVersion) {
gsStorage.setLastVersion(curVersion);

//show welcome message
const optionsUrl = chrome.extension.getURL('options.html?firstTime');
await gsChrome.tabsCreate(optionsUrl);
// Try to determine if this is a new install for the computer or for the whole profile
// If settings sync contains non-default options, then we can assume it's only
// a new install for this computer
if (!syncedSettingsOnInit || Object.keys(syncedSettingsOnInit).length === 0) {
//show welcome message
const optionsUrl = chrome.extension.getURL('options.html?firstTime');
await gsChrome.tabsCreate(optionsUrl);
}
}

async function handleUpdate(currentSessionTabs, curVersion, lastVersion) {
Expand Down Expand Up @@ -970,6 +980,7 @@ var gsSession = (function() {
getTabCheckTimeTakenInSeconds,
getRecoveryTimeTakenInSeconds,
getStartupType,
setSynchedSettingsOnInit,
getStartupLastVersion,
recoverLostTabs,
triggerDiscardOfAllTabs,
Expand Down
4 changes: 2 additions & 2 deletions src/js/gsStorage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*global chrome, gsAnalytics, localStorage, gsUtils */
/*global chrome, gsAnalytics, gsSession, localStorage, gsUtils */
'use strict';

var gsStorage = {
Expand Down Expand Up @@ -72,6 +72,7 @@ var gsStorage = {
var defaultKeys = Object.keys(defaultSettings);
chrome.storage.sync.get(defaultKeys, function(syncedSettings) {
gsUtils.log('gsStorage', 'syncedSettings on init: ', syncedSettings);
gsSession.setSynchedSettingsOnInit(syncedSettings);

var rawLocalSettings;
try {
Expand Down Expand Up @@ -293,7 +294,6 @@ var gsStorage = {
);
}
},
isNewInstall: function() {},

fetchNoticeVersion: function() {
var lastNoticeVersion;
Expand Down

0 comments on commit e339c8d

Please sign in to comment.