mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
move
This commit is contained in:
parent
6e1f8a08b3
commit
c2fc2577e0
2 changed files with 22 additions and 13 deletions
|
|
@ -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<IVoidUpdateService>(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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue