Browse Source

Adds upgrade to pro notification

main
Eric Amodio 2 years ago
parent
commit
6550ded970
3 changed files with 31 additions and 0 deletions
  1. +19
    -0
      src/messages.ts
  2. +11
    -0
      src/plus/subscription/subscriptionService.ts
  3. +1
    -0
      src/storage.ts

+ 19
- 0
src/messages.ts View File

@ -2,6 +2,7 @@ import type { MessageItem } from 'vscode';
import { ConfigurationTarget, window } from 'vscode';
import { configuration, SuppressedMessages } from './configuration';
import { Commands } from './constants';
import type { Container } from './container';
import type { GitCommit } from './git/models/commit';
import { Logger } from './logger';
import { executeCommand } from './system/command';
@ -172,6 +173,24 @@ export function showIntegrationRequestTimedOutWarningMessage(providerName: strin
);
}
export async function showProDiscountNotification(container: Container): Promise<void> {
if (container.storage.get('plus:discountNotificationShown', false)) return;
void container.storage.store('plus:discountNotificationShown', true);
const upgrade: MessageItem = { title: 'Upgrade to Pro' };
const result = await showMessage(
'info',
'GitLens Pro introductory pricing, up to a 60% discount, goes away tomorrow. Upgrade to GitLens Pro now to access [GitLens+ features](command:gitlens.plus.learn) on private repos at a reduced rate.',
undefined,
undefined,
upgrade,
);
if (result === upgrade) {
void container.subscription.purchase();
}
}
export async function showWhatsNewMessage(version: string) {
const whatsnew = { title: "See What's New" };
const result = await showMessage(

+ 11
- 0
src/plus/subscription/subscriptionService.ts View File

@ -27,6 +27,7 @@ import { setContext } from '../../context';
import { AccountValidationError } from '../../errors';
import type { RepositoriesChangeEvent } from '../../git/gitProviderService';
import { Logger } from '../../logger';
import { showProDiscountNotification } from '../../messages';
import type { Subscription } from '../../subscription';
import {
computeSubscriptionState,
@ -843,6 +844,16 @@ export class SubscriptionService implements Disposable {
this._subscription = subscription;
this._etag = Date.now();
setTimeout(() => {
if (
new Date() < new Date('2022-10-18T00:00:00.000Z') &&
subscription!.account != null &&
!isSubscriptionPaid(subscription!)
) {
void showProDiscountNotification(this.container);
}
}, 5000);
if (!silent) {
this.updateContext();

+ 1
- 0
src/storage.ts View File

@ -144,6 +144,7 @@ export interface GlobalStorage {
pendingWhatsNewOnFocus?: boolean;
plus: {
migratedAuthentication?: boolean;
discountNotificationShown?: boolean;
};
// Don't change this key name ('premium`) as its the stored subscription
premium: {

Loading…
Cancel
Save