Skip to content

Commit 43dfd3f

Browse files
author
Alan Fleming
committed
Tweak restoration
1 parent 29da2bd commit 43dfd3f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

python/jupyterlab_widgets/src/manager.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ export abstract class LabWidgetManager
112112
super.disconnect();
113113
this._restoredStatus = false;
114114
}
115-
get disconnected() {
116-
return !this._restoredStatus;
117-
}
118115

119116
protected async _loadFromKernel(): Promise<void> {
120117
if (!this.kernel) {
@@ -419,9 +416,7 @@ export class KernelWidgetManager extends LabWidgetManager {
419416
this._handleKernelConnectionStatusChange,
420417
this
421418
);
422-
this._restoredStatus = false;
423-
this._kernelRestoreInProgress = true;
424-
this.clear_state().then(() => this.restoreWidgets());
419+
this.restoreWidgets();
425420
}
426421

427422
/**
@@ -476,7 +471,7 @@ export class KernelWidgetManager extends LabWidgetManager {
476471

477472
static existsWithActiveKenel(id: string) {
478473
const widgetManager = Private.managers.get(id);
479-
return !widgetManager?.disconnected;
474+
return widgetManager?._restoredStatus;
480475
}
481476

482477
/**
@@ -515,7 +510,10 @@ export class KernelWidgetManager extends LabWidgetManager {
515510
* Restore widgets from kernel.
516511
*/
517512
async restoreWidgets(): Promise<void> {
513+
this._restoredStatus = false;
514+
this._kernelRestoreInProgress = true;
518515
try {
516+
await this.clear_state();
519517
await this._loadFromKernel();
520518
} catch (err) {
521519
// Do nothing

0 commit comments

Comments
 (0)