From e192c547b1c28bb98e0ceefec43ef6b7ea4694b0 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 4 Sep 2017 03:26:18 -0400 Subject: [PATCH] Fixes #130 - Stops repeated welcome for some users No idea why the version check fails, but hopefully this will help --- CHANGELOG.md | 1 + src/messages.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49a9c44..216d513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed - Fixes an issue where remote branches couldn't be opened properly in their remote service +- Fixes [#130](https://github.com/eamodio/vscode-gitlens/issues/130) - First-run "Thank you for choosing GitLens! [...]" info message shown on every start up ## [4.4.3] - 2017-08-30 ## Fixed diff --git a/src/messages.ts b/src/messages.ts index c842691..39e804f 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -11,7 +11,8 @@ export type SuppressedKeys = 'suppressCommitHasNoPreviousCommitWarning' | 'suppressGitVersionWarning' | 'suppressLineUncommittedWarning' | 'suppressNoRepositoryWarning' | - 'suppressUpdateNotice'; + 'suppressUpdateNotice' | + 'suppressWelcomeNotice'; export const SuppressedKeys = { CommitHasNoPreviousCommitWarning: 'suppressCommitHasNoPreviousCommitWarning' as SuppressedKeys, CommitNotFoundWarning: 'suppressCommitNotFoundWarning' as SuppressedKeys, @@ -19,7 +20,8 @@ export const SuppressedKeys = { GitVersionWarning: 'suppressGitVersionWarning' as SuppressedKeys, LineUncommittedWarning: 'suppressLineUncommittedWarning' as SuppressedKeys, NoRepositoryWarning: 'suppressNoRepositoryWarning' as SuppressedKeys, - UpdateNotice: 'suppressUpdateNotice' as SuppressedKeys + UpdateNotice: 'suppressUpdateNotice' as SuppressedKeys, + WelcomeNotice: 'suppressWelcomeNotice' as SuppressedKeys }; export class Messages { @@ -65,7 +67,7 @@ export class Messages { static async showWelcomeMessage(): Promise { const viewDocs = 'View Docs'; - const result = await window.showInformationMessage(`Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, viewDocs); + const result = await Messages._showMessage('info', `Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, SuppressedKeys.WelcomeNotice, null, viewDocs); if (result === viewDocs) { commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens')); } @@ -73,7 +75,7 @@ export class Messages { } private static async _showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise { - Logger.log(`ShowMessage(${type}, "${message}", ${suppressionKey}, ${dontShowAgain})`); + Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`); if (Messages.context.globalState.get(suppressionKey, false)) { Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) skipped`); @@ -100,12 +102,13 @@ export class Messages { } if (dontShowAgain === null || result === dontShowAgain) { - Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) don't show again requested`); + Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested`); await Messages.context.globalState.update(suppressionKey, true); - return undefined; + + if (result === dontShowAgain) return undefined; } - Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) returned ${result}`); + Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) returned ${result}`); return result; } } \ No newline at end of file