mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
fixes #56736
This commit is contained in:
@@ -13,9 +13,8 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
|
||||
import { IGlobalActivityRegistry, GlobalActivityExtensions } from 'vs/workbench/common/activity';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution, WinUserSetupContribution } from './update';
|
||||
import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution } from './update';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import product from 'vs/platform/node/product';
|
||||
|
||||
const workbench = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
|
||||
@@ -25,10 +24,6 @@ if (platform.isWindows) {
|
||||
if (process.arch === 'ia32') {
|
||||
workbench.registerWorkbenchContribution(Win3264BitContribution, LifecyclePhase.Running);
|
||||
}
|
||||
|
||||
if (product.target !== 'user') {
|
||||
workbench.registerWorkbenchContribution(WinUserSetupContribution, LifecyclePhase.Running);
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IGlobalActivityRegistry>(GlobalActivityExtensions)
|
||||
|
||||
@@ -21,7 +21,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IUpdateService, State as UpdateState, StateType, IUpdate, UpdateType } from 'vs/platform/update/common/update';
|
||||
import { IUpdateService, State as UpdateState, StateType, IUpdate } from 'vs/platform/update/common/update';
|
||||
import * as semver from 'semver';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INotificationService, INotificationHandle } from 'vs/platform/notification/common/notification';
|
||||
@@ -209,133 +209,6 @@ export class Win3264BitContribution implements IWorkbenchContribution {
|
||||
}
|
||||
}
|
||||
|
||||
async function isUserSetupInstalled(): Promise<boolean> {
|
||||
const rawUserAppId = process.arch === 'x64' ? product.win32x64UserAppId : product.win32UserAppId;
|
||||
const userAppId = rawUserAppId.replace(/^\{\{/, '{');
|
||||
const Registry = await import('winreg');
|
||||
const key = new Registry({
|
||||
hive: Registry.HKCU,
|
||||
key: `\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${userAppId}_is1`
|
||||
});
|
||||
|
||||
try {
|
||||
await new Promise((c, e) => key.get('', (err, result) => err ? e(err) : c(result)));
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export class WinUserSetupContribution implements IWorkbenchContribution {
|
||||
|
||||
private static readonly KEY = 'update/win32-usersetup';
|
||||
private static readonly KEY_BOTH = 'update/win32-usersetup-both';
|
||||
|
||||
private static readonly STABLE_URL = 'https://vscode-update.azurewebsites.net/latest/win32-x64-user/stable';
|
||||
private static readonly STABLE_URL_32BIT = 'https://vscode-update.azurewebsites.net/latest/win32-user/stable';
|
||||
private static readonly INSIDER_URL = 'https://vscode-update.azurewebsites.net/latest/win32-x64-user/insider';
|
||||
private static readonly INSIDER_URL_32BIT = 'https://vscode-update.azurewebsites.net/latest/win32-user/insider';
|
||||
|
||||
// TODO@joao this needs to change to the 1.26 release notes
|
||||
private static readonly READ_MORE = 'https://aka.ms/vscode-win32-user-setup';
|
||||
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@IOpenerService private openerService: IOpenerService,
|
||||
@IUpdateService private updateService: IUpdateService
|
||||
) {
|
||||
if (!environmentService.isBuilt) {
|
||||
return;
|
||||
}
|
||||
|
||||
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY_BOTH, this.storageService);
|
||||
|
||||
if (!neverShowAgain.shouldShow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
isUserSetupInstalled().then(userSetupIsInstalled => {
|
||||
if (!userSetupIsInstalled) {
|
||||
updateService.onStateChange(this.onUpdateStateChange, this, this.disposables);
|
||||
this.onUpdateStateChange(this.updateService.state);
|
||||
return;
|
||||
}
|
||||
|
||||
const handle = this.notificationService.prompt(
|
||||
severity.Info,
|
||||
nls.localize('usersetupsystem', "You are running the system-wide installation of {0}, while having the user-wide distribution installed as well.", product.nameShort),
|
||||
[
|
||||
{ label: nls.localize('ok', "OK"), run: () => null },
|
||||
{
|
||||
label: nls.localize('okneveragain', "OK, Don't Show Again"),
|
||||
run: () => {
|
||||
neverShowAgain.action.run(handle);
|
||||
neverShowAgain.action.dispose();
|
||||
}
|
||||
}]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private onUpdateStateChange(state: UpdateState): void {
|
||||
if (state.type !== StateType.Idle) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.updateType !== UpdateType.Setup) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.environmentService.isBuilt || this.environmentService.disableUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
const neverShowAgain = new NeverShowAgain(WinUserSetupContribution.KEY, this.storageService);
|
||||
|
||||
if (!neverShowAgain.shouldShow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const handle = this.notificationService.prompt(
|
||||
severity.Info,
|
||||
nls.localize('usersetup', "We recommend switching to our new User Setup distribution of {0} for Windows!", product.nameShort),
|
||||
[
|
||||
{
|
||||
label: nls.localize('learnMore', "Learn More"),
|
||||
run: () => {
|
||||
return this.openerService.open(URI.parse(WinUserSetupContribution.READ_MORE));
|
||||
}
|
||||
},
|
||||
{
|
||||
label: nls.localize('downloadnow', "Download"),
|
||||
run: () => {
|
||||
const url = product.quality === 'insider'
|
||||
? (process.arch === 'ia32' ? WinUserSetupContribution.INSIDER_URL_32BIT : WinUserSetupContribution.INSIDER_URL)
|
||||
: (process.arch === 'ia32' ? WinUserSetupContribution.STABLE_URL_32BIT : WinUserSetupContribution.STABLE_URL);
|
||||
|
||||
return this.openerService.open(URI.parse(url));
|
||||
}
|
||||
},
|
||||
{
|
||||
label: nls.localize('neveragain', "Don't Show Again"),
|
||||
run: () => {
|
||||
neverShowAgain.action.run(handle);
|
||||
neverShowAgain.action.dispose();
|
||||
}
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
}
|
||||
}
|
||||
|
||||
class CommandAction extends Action {
|
||||
|
||||
constructor(
|
||||
|
||||
Reference in New Issue
Block a user