Skip to content

Commit 821fa1c

Browse files
committed
Fixes #130 - Stops repeated welcome for some users
No idea why the version check fails, but hopefully this will help
1 parent 3835193 commit 821fa1c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/messages.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ export type SuppressedKeys = 'suppressCommitHasNoPreviousCommitWarning' |
1111
'suppressGitVersionWarning' |
1212
'suppressLineUncommittedWarning' |
1313
'suppressNoRepositoryWarning' |
14-
'suppressUpdateNotice';
14+
'suppressUpdateNotice' |
15+
'suppressWelcomeNotice';
1516
export const SuppressedKeys = {
1617
CommitHasNoPreviousCommitWarning: 'suppressCommitHasNoPreviousCommitWarning' as SuppressedKeys,
1718
CommitNotFoundWarning: 'suppressCommitNotFoundWarning' as SuppressedKeys,
1819
FileNotUnderSourceControlWarning: 'suppressFileNotUnderSourceControlWarning' as SuppressedKeys,
1920
GitVersionWarning: 'suppressGitVersionWarning' as SuppressedKeys,
2021
LineUncommittedWarning: 'suppressLineUncommittedWarning' as SuppressedKeys,
2122
NoRepositoryWarning: 'suppressNoRepositoryWarning' as SuppressedKeys,
22-
UpdateNotice: 'suppressUpdateNotice' as SuppressedKeys
23+
UpdateNotice: 'suppressUpdateNotice' as SuppressedKeys,
24+
WelcomeNotice: 'suppressWelcomeNotice' as SuppressedKeys
2325
};
2426

2527
export class Messages {
@@ -65,15 +67,15 @@ export class Messages {
6567

6668
static async showWelcomeMessage(): Promise<string | undefined> {
6769
const viewDocs = 'View Docs';
68-
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);
70+
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);
6971
if (result === viewDocs) {
7072
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens'));
7173
}
7274
return result;
7375
}
7476

7577
private static async _showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
76-
Logger.log(`ShowMessage(${type}, "${message}", ${suppressionKey}, ${dontShowAgain})`);
78+
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`);
7779

7880
if (Messages.context.globalState.get(suppressionKey, false)) {
7981
Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) skipped`);
@@ -100,12 +102,13 @@ export class Messages {
100102
}
101103

102104
if (dontShowAgain === null || result === dontShowAgain) {
103-
Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) don't show again requested`);
105+
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested`);
104106
await Messages.context.globalState.update(suppressionKey, true);
105-
return undefined;
107+
108+
if (result === dontShowAgain) return undefined;
106109
}
107110

108-
Logger.log(`ShowMessage(${type}, ${message}, ${suppressionKey}, ${dontShowAgain}) returned ${result}`);
111+
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) returned ${result}`);
109112
return result;
110113
}
111114
}

0 commit comments

Comments
 (0)