Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cancellable option for withProgress #6365

Merged
merged 1 commit into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,14 +686,15 @@ export interface DecorationProvider {
}

export interface NotificationMain {
$startProgress(options: string | NotificationMain.StartProgressOptions): Promise<string>;
$startProgress(options: NotificationMain.StartProgressOptions): Promise<string>;
$stopProgress(id: string): void;
$updateProgress(id: string, report: NotificationMain.ProgressReport): void;
}
export namespace NotificationMain {
export interface StartProgressOptions {
title: string;
location?: string;
cancellable?: boolean;
}
export interface ProgressReport {
message?: string;
Expand Down
9 changes: 4 additions & 5 deletions packages/plugin-ext/src/main/browser/notification-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NotificationMainImpl implements NotificationMain, Disposable {
this.toDispose.dispose();
}

async $startProgress(options: string | NotificationMain.StartProgressOptions): Promise<string> {
async $startProgress(options: NotificationMain.StartProgressOptions): Promise<string> {
const progressMessage = this.mapOptions(options);
const progress = await this.progressService.showProgress(progressMessage);
const id = progress.id;
Expand All @@ -51,10 +51,9 @@ export class NotificationMainImpl implements NotificationMain, Disposable {
}
return id;
}
protected mapOptions(options: string | NotificationMain.StartProgressOptions): ProgressMessage {
const text = typeof options === 'string' ? options : options.title;
const location = typeof options === 'string' ? 'notification' : options.location;
return { text, options: { location, cancelable: true } };
protected mapOptions(options: NotificationMain.StartProgressOptions): ProgressMessage {
const { title, location, cancellable } = options;
return { text: title, options: { location, cancelable: cancellable } };
}

$stopProgress(id: string): void {
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/plugin/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class NotificationExtImpl implements NotificationExt {
const progress = task({ report: async item => this.proxy.$updateProgress(await id.promise, item)}, tokenSource.token);
const title = options.title ? options.title : '';
const location = this.mapLocation(options.location);
id.resolve(await this.proxy.$startProgress({ title, location }));
const cancellable = options.cancellable;
id.resolve(await this.proxy.$startProgress({ title, location, cancellable }));
const stop = async () => this.proxy.$stopProgress(await id.promise);
const promise = Promise.all([
progress,
Expand Down