mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(plugin-data-viewer): CB-1305 fetch cancellation
This commit is contained in:
+4
-1
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { makeObservable, observable } from 'mobx';
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ITask, TaskScheduler } from '@cloudbeaver/core-executor';
|
||||
|
||||
@@ -37,6 +37,9 @@ export class ConnectionExecutionContext implements IConnectionExecutionContext {
|
||||
this.currentTask = null;
|
||||
makeObservable<this, 'currentTask'>(this, {
|
||||
currentTask: observable.ref,
|
||||
context: computed,
|
||||
executing: computed,
|
||||
cancellable: computed,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { makeObservable, observable } from 'mobx';
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ITask } from './ITask';
|
||||
|
||||
@@ -15,7 +15,11 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
executing: boolean;
|
||||
|
||||
get cancellable(): boolean {
|
||||
return !this.cancelled && (!this.executing || !!this.externalCancel);
|
||||
if (this.cancelled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !this.executing || this.externalCancel !== undefined;
|
||||
}
|
||||
|
||||
private resolve!: (value: TValue) => void;
|
||||
@@ -38,6 +42,7 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
this.executing = false;
|
||||
|
||||
makeObservable(this, {
|
||||
cancellable: computed,
|
||||
cancelled: observable,
|
||||
executing: observable,
|
||||
});
|
||||
@@ -107,6 +112,10 @@ export class Task<TValue> implements ITask<TValue> {
|
||||
}
|
||||
|
||||
cancel(): Promise<void> | void {
|
||||
if (this.cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cancelled = true;
|
||||
|
||||
if (!this.executing) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { computed, makeObservable, observable } from 'mobx';
|
||||
|
||||
import type { ConnectionExecutionContextService, IConnectionExecutionContext, IConnectionExecutionContextInfo } from '@cloudbeaver/core-connections';
|
||||
import type { NotificationService } from '@cloudbeaver/core-events';
|
||||
import type { ITask } from '@cloudbeaver/core-executor';
|
||||
@@ -38,6 +40,11 @@ export class ContainerDataSource extends DatabaseDataSource<IDataContainerOption
|
||||
|
||||
this.currentTask = null;
|
||||
this.executionContext = null;
|
||||
|
||||
makeObservable(this, {
|
||||
currentTask: observable.ref,
|
||||
canCancel: computed,
|
||||
});
|
||||
}
|
||||
|
||||
isDisabled(resultIndex: number): boolean {
|
||||
|
||||
Reference in New Issue
Block a user