Browse Source

Adds what's new notification if page is disabled

main
Eric Amodio 6 years ago
parent
commit
b7da064db6
2 changed files with 45 additions and 13 deletions
  1. +13
    -12
      src/extension.ts
  2. +32
    -1
      src/messages.ts

+ 13
- 12
src/extension.ts View File

@ -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);
}
}

+ 32
- 1
src/messages.ts View File

@ -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';
@ -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
@ -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,

Loading…
Cancel
Save