Skip to content

Commit

Permalink
Fixes #130 - Stops repeated welcome for some users
Browse files Browse the repository at this point in the history
No idea why the version check fails, but hopefully this will help
  • Loading branch information
eamodio committed Sep 4, 2017
1 parent 3835193 commit 821fa1c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ export type SuppressedKeys = 'suppressCommitHasNoPreviousCommitWarning' |
'suppressGitVersionWarning' |
'suppressLineUncommittedWarning' |
'suppressNoRepositoryWarning' |
'suppressUpdateNotice';
'suppressUpdateNotice' |
'suppressWelcomeNotice';
export const SuppressedKeys = {
CommitHasNoPreviousCommitWarning: 'suppressCommitHasNoPreviousCommitWarning' as SuppressedKeys,
CommitNotFoundWarning: 'suppressCommitNotFoundWarning' as SuppressedKeys,
FileNotUnderSourceControlWarning: 'suppressFileNotUnderSourceControlWarning' as 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 {
Expand Down Expand Up @@ -65,15 +67,15 @@ export class Messages {

static async showWelcomeMessage(): Promise<string | undefined> {
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'));
}
return result;
}

private static async _showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
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`);
Expand All @@ -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;
}
}

0 comments on commit 821fa1c

Please sign in to comment.