diff --git a/src/vs/platform/void/common/voidUpdateService.ts b/src/vs/platform/void/common/voidUpdateService.ts index 5ba02fde..2f4a6264 100644 --- a/src/vs/platform/void/common/voidUpdateService.ts +++ b/src/vs/platform/void/common/voidUpdateService.ts @@ -7,7 +7,6 @@ import { createDecorator } from '../../instantiation/common/instantiation.js'; import { ProxyChannel } from '../../../base/parts/ipc/common/ipc.js'; import { IMainProcessService } from '../../ipc/common/mainProcessService.js'; import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; -import { INotificationService, Severity } from '../../notification/common/notification.js'; @@ -28,7 +27,6 @@ export class VoidUpdateService implements IVoidUpdateService { constructor( @IMainProcessService mainProcessService: IMainProcessService, // (only usable on client side) - @INotificationService private readonly notifService: INotificationService, ) { // creates an IPC proxy to use metricsMainService.ts this.voidUpdateService = ProxyChannel.toService(mainProcessService.getChannel('void-channel-update')); @@ -39,13 +37,6 @@ export class VoidUpdateService implements IVoidUpdateService { // anything transmitted over a channel must be async even if it looks like it doesn't have to be check: IVoidUpdateService['check'] = async () => { const res = await this.voidUpdateService.check() - const message = res?.message - - this.notifService.notify({ - severity: Severity.Info, - message: message ?? 'This is a very old version of void, please download the latest version! [Void Editor](https://voideditor.com/download-beta)! ', - }) - return res } } diff --git a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts index cd8b9dde..d45e4e55 100644 --- a/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts +++ b/src/vs/workbench/contrib/void/browser/voidUpdateActions.ts @@ -4,13 +4,26 @@ *--------------------------------------------------------------------------------------*/ import { Disposable } from '../../../../base/common/lifecycle.js'; +import Severity from '../../../../base/common/severity.js'; import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js'; import { localize2 } from '../../../../nls.js'; import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js'; +import { INotificationService } from '../../../../platform/notification/common/notification.js'; import { IVoidUpdateService } from '../../../../platform/void/common/voidUpdateService.js'; import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js'; +const afterGetRes = (res: null | { message: string }, notifService: INotificationService) => { + if (res === null) return + + const message = res?.message ?? 'This is a very old version of void, please download the latest version! [Void Editor](https://voideditor.com/download-beta)! ' + + notifService.notify({ + severity: Severity.Info, + message: message, + }) +} + // Action registerAction2(class extends Action2 { @@ -22,10 +35,11 @@ registerAction2(class extends Action2 { }); } async run(accessor: ServicesAccessor): Promise { - const voidUpdateService = accessor.get(IVoidUpdateService) - voidUpdateService.check() + const notifService = accessor.get(INotificationService) + const res = await voidUpdateService.check() + afterGetRes(res, notifService) } }) @@ -33,10 +47,14 @@ registerAction2(class extends Action2 { class VoidUpdateWorkbenchContribution extends Disposable implements IWorkbenchContribution { static readonly ID = 'workbench.contrib.void.voidUpdate' constructor( - @IVoidUpdateService private readonly voidUpdateService: IVoidUpdateService + @IVoidUpdateService private readonly voidUpdateService: IVoidUpdateService, + @INotificationService private readonly notifService: INotificationService ) { super() - setTimeout(() => { this.voidUpdateService.check() }, 5 * 1000) + setTimeout(async () => { + const res = await this.voidUpdateService.check() + afterGetRes(res, this.notifService) + }, 5 * 1000) } } registerWorkbenchContribution2(VoidUpdateWorkbenchContribution.ID, VoidUpdateWorkbenchContribution, WorkbenchPhase.BlockRestore);