From 29a3a2ac58f53e31519f2d463fa3c5e502d585f0 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 13 Sep 2021 12:00:32 -0700 Subject: [PATCH] WhatsNew: Save build creation time, use as displayed date --- Gruntfile.js | 5 +++-- config/default.json | 1 + main.js | 1 + preload.js | 2 ++ ts/components/WhatsNew.tsx | 2 +- ts/window.d.ts | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5552e04c4..1820470e7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -158,10 +158,11 @@ module.exports = grunt => { grunt.task.requires('gitinfo'); const gitinfo = grunt.config.get('gitinfo'); const committed = gitinfo.local.branch.current.lastCommitTime; - const time = Date.parse(committed) + 1000 * 60 * 60 * 24 * 90; + const buildCreation = Date.parse(committed); + const buildExpiration = buildCreation + 1000 * 60 * 60 * 24 * 90; grunt.file.write( 'config/local-production.json', - `${JSON.stringify({ buildExpiration: time })}\n` + `${JSON.stringify({ buildCreation, buildExpiration })}\n` ); }); diff --git a/config/default.json b/config/default.json index 39fa3ecd2..338d64cab 100644 --- a/config/default.json +++ b/config/default.json @@ -15,6 +15,7 @@ "updatesEnabled": false, "enableCI": false, "openDevTools": false, + "buildCreation": 0, "buildExpiration": 0, "certificateAuthority": "-----BEGIN CERTIFICATE-----\nMIID7zCCAtegAwIBAgIJAIm6LatK5PNiMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYD\nVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5j\naXNjbzEdMBsGA1UECgwUT3BlbiBXaGlzcGVyIFN5c3RlbXMxHTAbBgNVBAsMFE9w\nZW4gV2hpc3BlciBTeXN0ZW1zMRMwEQYDVQQDDApUZXh0U2VjdXJlMB4XDTEzMDMy\nNTIyMTgzNVoXDTIzMDMyMzIyMTgzNVowgY0xCzAJBgNVBAYTAlVTMRMwEQYDVQQI\nDApDYWxpZ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a/main.js b/main.js index 899ead8f2..d99134db9 100644 --- a/main.js +++ b/main.js @@ -253,6 +253,7 @@ function prepareUrl( name: packageJson.productName, locale: locale.name, version: app.getVersion(), + buildCreation: config.get('buildCreation'), buildExpiration: config.get('buildExpiration'), serverUrl: config.get('serverUrl'), storageUrl: config.get('storageUrl'), diff --git a/preload.js b/preload.js index 55819a7e4..d44a64466 100644 --- a/preload.js +++ b/preload.js @@ -13,6 +13,7 @@ try { const semver = require('semver'); const _ = require('lodash'); const { strictAssert } = require('./ts/util/assert'); + const { parseIntWithFallback } = require('./ts/util/parseIntWithFallback'); // It is important to call this as early as possible require('./ts/windows/context'); @@ -58,6 +59,7 @@ try { window.getEnvironment = getEnvironment; window.getAppInstance = () => config.appInstance; window.getVersion = () => config.version; + window.getBuildCreation = () => parseIntWithFallback(config.buildCreation, 0); window.getExpiration = () => { const sixtyDays = 60 * 86400 * 1000; const remoteBuildExpiration = window.storage.get('remoteBuildExpiration'); diff --git a/ts/components/WhatsNew.tsx b/ts/components/WhatsNew.tsx index a7048c688..a09dc82ea 100644 --- a/ts/components/WhatsNew.tsx +++ b/ts/components/WhatsNew.tsx @@ -26,7 +26,7 @@ export const WhatsNew = ({ i18n }: PropsType): JSX.Element => { const viewReleaseNotes = () => { setReleaseNotes({ - date: new Date('09/02/2021'), + date: new Date(window.getBuildCreation?.() || Date.now()), version: window.getVersion(), features: ['WhatsNew__v5.17--1', 'WhatsNew__v5.17--2'], }); diff --git a/ts/window.d.ts b/ts/window.d.ts index 5ab57a5f8..97b139d48 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -199,6 +199,7 @@ declare global { getAccountManager: () => AccountManager; getBuiltInImages: () => Promise>; getConversations: () => ConversationModelCollectionType; + getBuildCreation: () => number; getEnvironment: typeof getEnvironment; getExpiration: () => string; getGuid: () => string;