From 43efe22b5cf4fabb6f01b831caa307c77047e233 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 6 Nov 2024 10:55:58 +0100 Subject: [PATCH] Add a comment --- packages/cli-repl/src/cli-repl.ts | 2 ++ packages/cli-repl/src/update-notification-manager.ts | 10 +++++++--- packages/types/src/index.ts | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/cli-repl/src/cli-repl.ts b/packages/cli-repl/src/cli-repl.ts index a1ec1202c..c9756ec1a 100644 --- a/packages/cli-repl/src/cli-repl.ts +++ b/packages/cli-repl/src/cli-repl.ts @@ -1287,6 +1287,8 @@ export class CliRepl implements MongoshIOProvider { latest: await this.updateNotificationManager.getLatestVersionIfMoreRecent(''), currentVersion, + hasGreetingCTA: + !!(await this.updateNotificationManager.getGreetingCTAForCurrentVersion()), }); } catch (err: any) { this.bus.emit('mongosh:error', err, 'startup'); diff --git a/packages/cli-repl/src/update-notification-manager.ts b/packages/cli-repl/src/update-notification-manager.ts index 87ff1a16f..b459fbc2a 100644 --- a/packages/cli-repl/src/update-notification-manager.ts +++ b/packages/cli-repl/src/update-notification-manager.ts @@ -184,9 +184,13 @@ export class UpdateNotificationManager { latestKnownMongoshVersion: this.latestKnownMongoshVersion, cta: { [currentVersion]: this.currentVersionGreetingCTA, - ...(this.latestKnownMongoshVersion && { - [this.latestKnownMongoshVersion]: latestKnownVersionCTA, - }), + + // Add the latest known version's CTA if we're not already on latest. This could be used + // next time we start mongosh if the user has updated to latest. + ...(this.latestKnownMongoshVersion && + this.latestKnownMongoshVersion !== currentVersion && { + [this.latestKnownMongoshVersion]: latestKnownVersionCTA, + }), }, }; await fs.writeFile(localFilePath, JSON.stringify(localFileContents)); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 39f8190f4..22da72a78 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -179,6 +179,7 @@ export interface FetchingUpdateMetadataEvent { export interface FetchingUpdateMetadataCompleteEvent { latest: string | null; currentVersion: string; + hasGreetingCTA: boolean; } export interface SessionStartedEvent {