From 170cf0beeacc0b96d92d31de4a495e8fb3008509 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 31 Mar 2020 15:45:52 -0700 Subject: [PATCH] Add isFirstSession property to context --- modules/core/context.js | 1 + modules/ui/splash.js | 5 +++-- modules/ui/version.js | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/core/context.js b/modules/core/context.js index ec18e7580..e7d2d0f73 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -55,6 +55,7 @@ export function coreContext() { /* eslint-enable no-console */ } }; + context.isFirstSession = !context.storage('sawSplash') && !context.storage('sawPrivacyVersion'); /* User interface and keybinding */ diff --git a/modules/ui/splash.js b/modules/ui/splash.js index 904f56e73..684b3dfc3 100644 --- a/modules/ui/splash.js +++ b/modules/ui/splash.js @@ -14,12 +14,13 @@ export function uiSplash(context) { // If user has not seen this version of the privacy policy, show the splash again. let updateMessage = ''; const sawPrivacyVersion = context.storage('sawPrivacyVersion'); + let showSplash = !context.storage('sawSplash'); if (sawPrivacyVersion !== context.privacyVersion) { updateMessage = t('splash.privacy_update'); - context.storage('sawSplash', null); + showSplash = true; } - if (context.storage('sawSplash')) return; + if (!showSplash) return; context.storage('sawSplash', true); context.storage('sawPrivacyVersion', context.privacyVersion); diff --git a/modules/ui/version.js b/modules/ui/version.js index 9a8b493a7..a46f2e77c 100644 --- a/modules/ui/version.js +++ b/modules/ui/version.js @@ -15,8 +15,13 @@ export function uiVersion(context) { var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/); if (sawVersion === null && matchedVersion !== null) { - isNewVersion = (context.storage('sawVersion') !== currVersion); - isNewUser = !context.storage('sawSplash'); + if (context.storage('sawVersion')) { + isNewUser = false; + isNewVersion = context.storage('sawVersion') !== currVersion; + } else { + isNewUser = true; + isNewVersion = true; + } context.storage('sawVersion', currVersion); sawVersion = currVersion; }