Skip to content

Commit

Permalink
Adds what's new notification if page is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 30, 2018
1 parent 6483c19 commit b7da064
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,22 @@ async function showWelcomePage(version: string, previousVersion: string | undefi

if (previousVersion !== version) {
Logger.log(`GitLens upgraded from v${previousVersion} to v${version}`);

if (Versions.compare(Versions.fromString(previousVersion), Versions.from(8, 0, 0)) === 0) {
await commands.executeCommand(Commands.ShowWelcomePage);

return;
}
}

if (!Container.config.showWhatsNewAfterUpgrades) return;

const [major, minor] = version.split('.');
const [prevMajor, prevMinor] = previousVersion.split('.');
if (major === prevMajor && minor === prevMinor) return;
// Don't notify on downgrades
if (major < prevMajor || (major === prevMajor && minor < prevMinor)) return;
if (
(major === prevMajor && minor === prevMinor) ||
// Don't notify on downgrades
(major < prevMajor || (major === prevMajor && minor < prevMinor))
) {
return;
}

await commands.executeCommand(Commands.ShowWelcomePage);
if (Container.config.showWhatsNewAfterUpgrades) {
await commands.executeCommand(Commands.ShowWelcomePage);
}
else {
await Messages.showWhatsNewMessage(version);
}
}
33 changes: 32 additions & 1 deletion src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
import { commands, ConfigurationTarget, MessageItem, Uri, window } from 'vscode';
import { Commands } from './commands';
import { configuration, KeyMap } from './configuration';
import { BuiltInCommands, CommandContext, setCommandContext } from './constants';
import { Container } from './container';
Expand Down Expand Up @@ -145,7 +146,7 @@ export class Messages {

const result = await Messages.showMessage(
'info',
`While GitLens is offered to everyone for free, if you find it useful please consider supporting it. Thank you! ❤`,
`While GitLens is offered to everyone for free, if you find it useful, please consider [supporting](https://gitlens.amod.io/#support-gitlens) it. Thank you! ❤`,
undefined,
null,
...actions
Expand All @@ -171,6 +172,36 @@ export class Messages {
}
}

static async showWhatsNewMessage(version: string) {
const actions: MessageItem[] = [{ title: "What's New" }, { title: 'Release Notes' }, { title: '❤' }];

const result = await Messages.showMessage(
'info',
`GitLens has been updated to v${version} — check out what's new!`,
undefined,
null,
...actions
);

if (result != null) {
if (result === actions[0]) {
await commands.executeCommand(Commands.ShowWelcomePage);
}
else if (result === actions[1]) {
await commands.executeCommand(
BuiltInCommands.Open,
Uri.parse('https://github.com/eamodio/vscode-gitlens/blob/master/CHANGELOG.md')
);
}
else if (result === actions[2]) {
await commands.executeCommand(
BuiltInCommands.Open,
Uri.parse('https://gitlens.amod.io/#support-gitlens')
);
}
}
}

private static async showMessage<T extends MessageItem>(
type: 'info' | 'warn' | 'error',
message: string,
Expand Down

0 comments on commit b7da064

Please sign in to comment.