Skip to content

Commit

Permalink
IpylabModel
Browse files Browse the repository at this point in the history
added overload of save_changes to only save when com_live is true
JupyterFrontEndModel added close overload
  • Loading branch information
Alan Fleming committed Feb 20, 2024
1 parent 293c0d3 commit 9b77b1c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ipylab/main_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ def load(
return self.schedule_operation(
"load",
area=area,
options={"mode": mode, "rank": rank, "activate": activate, "ref": pack(ref)},
options={
"mode": InsertMode(mode),
"rank": rank,
"activate": activate,
"ref": pack(ref),
},
className=class_name,
)

Expand Down
10 changes: 10 additions & 0 deletions src/widgets/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ export class JupyterFrontEndModel extends IpylabModel {
this.save_changes();
}

close(comm_closed?: boolean): Promise<void> {
this.labShell.currentChanged.disconnect(this._updateSessionDetails, this);
this.labShell.activeChanged.disconnect(this._updateSessionDetails, this);
this.sessionManager.runningChanged.disconnect(
this._updateAllSessionDetails,
this
);
return super.close(comm_closed);
}

get shell(): JupyterFrontEnd.IShell {
return IpylabModel.app.shell;
}
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/ipylab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ export class IpylabModel extends DOMWidgetModel {
return super.close(comm_closed);
}

save_changes(callbacks?: {}): void {
if (this.comm_live) {
super.save_changes(callbacks);
}
}

static serializers: ISerializers = {
...WidgetModel.serializers
};
Expand Down

0 comments on commit 9b77b1c

Please sign in to comment.