@@ -72,7 +72,7 @@ const extension: JupyterFrontEndPlugin<void> = {
72
72
window . addEventListener ( 'beforeunload' , ( ) => {
73
73
localStorage . removeItem ( 'notebookValue' ) ;
74
74
} ) ;
75
- let localStorageValue = '' ;
75
+ let lastClusterName = '' ;
76
76
const panel = new Panel ( ) ;
77
77
panel . id = 'dpms-tab' ;
78
78
panel . title . icon = iconDpms ;
@@ -89,15 +89,15 @@ const extension: JupyterFrontEndPlugin<void> = {
89
89
90
90
91
91
panel . addWidget ( new dpmsWidget ( app as JupyterLab , themeManager ) ) ;
92
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
93
- if ( localStorageValue ) {
94
- loadDpmsWidget ( localStorageValue ) ;
92
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
93
+ if ( lastClusterName ) {
94
+ loadDpmsWidget ( lastClusterName ) ;
95
95
}
96
96
app . shell . add ( panel , 'left' , { rank : 1000 } ) ;
97
97
98
98
const onTitleChanged = async ( title : Title < Widget > ) => {
99
99
const widget = title . owner as NotebookPanel ;
100
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
100
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
101
101
if ( widget && widget instanceof NotebookPanel ) {
102
102
const kernel = widget . sessionContext . session ?. kernel ;
103
103
if ( kernel ) {
@@ -109,28 +109,28 @@ const extension: JupyterFrontEndPlugin<void> = {
109
109
const parts =
110
110
kernelSpec ?. resources . endpointParentResource . split ( '/' ) ;
111
111
const clusterValue = parts [ parts . length - 1 ] + '/clusters' ;
112
- if ( localStorageValue === null ) {
112
+ if ( lastClusterName === null ) {
113
113
localStorage . setItem ( 'notebookValue' , clusterValue ) ;
114
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
115
- loadDpmsWidget ( localStorageValue || '' ) ;
116
- } else if ( localStorageValue !== clusterValue ) {
114
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
115
+ loadDpmsWidget ( lastClusterName || '' ) ;
116
+ } else if ( lastClusterName !== clusterValue ) {
117
117
localStorage . setItem ( 'notebookValue' , clusterValue ) ;
118
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
119
- loadDpmsWidget ( localStorageValue || '' ) ;
118
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
119
+ loadDpmsWidget ( lastClusterName || '' ) ;
120
120
}
121
121
} else if (
122
122
kernelSpec ?. resources . endpointParentResource . includes ( '/sessions' )
123
123
) {
124
124
const parts = kernelSpec ?. name . split ( '-' ) ;
125
125
const sessionValue = parts . slice ( 1 ) . join ( '-' ) + '/sessions' ;
126
- if ( localStorageValue === null ) {
126
+ if ( lastClusterName === null ) {
127
127
localStorage . setItem ( 'notebookValue' , sessionValue ) ;
128
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
129
- loadDpmsWidget ( localStorageValue || '' ) ;
130
- } else if ( localStorageValue !== sessionValue ) {
128
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
129
+ loadDpmsWidget ( lastClusterName || '' ) ;
130
+ } else if ( lastClusterName !== sessionValue ) {
131
131
localStorage . setItem ( 'notebookValue' , sessionValue ) ;
132
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
133
- loadDpmsWidget ( localStorageValue || '' ) ;
132
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
133
+ loadDpmsWidget ( lastClusterName || '' ) ;
134
134
}
135
135
}
136
136
} else {
@@ -162,23 +162,23 @@ const extension: JupyterFrontEndPlugin<void> = {
162
162
newValue . title . label === 'Config Setup' ||
163
163
newValue . title . label === 'Clusters' ||
164
164
newValue . title . label === 'Serverless' ) &&
165
- localStorageValue !== ''
165
+ lastClusterName !== ''
166
166
) {
167
- localStorage . setItem ( 'oldNotebookValue' , localStorageValue || '' ) ;
167
+ localStorage . setItem ( 'oldNotebookValue' , lastClusterName || '' ) ;
168
168
localStorage . removeItem ( 'notebookValue' ) ;
169
- localStorageValue = '' ;
169
+ lastClusterName = '' ;
170
170
loadDpmsWidget ( '' ) ;
171
171
} else {
172
172
if (
173
- localStorageValue === '' &&
173
+ lastClusterName === '' &&
174
174
newValue . title . label !== 'Launcher' &&
175
175
newValue . title . label !== 'Config Setup' &&
176
176
newValue . title . label !== 'Clusters' &&
177
177
newValue . title . label !== 'Serverless'
178
178
) {
179
179
let oldNotebook = localStorage . getItem ( 'oldNotebookValue' ) ;
180
180
localStorage . setItem ( 'notebookValue' , oldNotebook || '' ) ;
181
- localStorageValue = localStorage . getItem ( 'notebookValue' ) || '' ;
181
+ lastClusterName = localStorage . getItem ( 'notebookValue' ) || '' ;
182
182
loadDpmsWidget ( oldNotebook || '' ) ;
183
183
}
184
184
}
0 commit comments