@@ -158,35 +158,37 @@ export const statusBarTimeline: JupyterFrontEndPlugin<void> = {
158
158
documentPath : string ,
159
159
documentId : string
160
160
) => {
161
- if ( drive ) {
162
- // Remove 'RTC:' from document path
163
- documentPath = documentPath . slice ( drive . name . length + 1 ) ;
164
- // Dispose of the previous timelineWidget if it exists
165
- if ( timelineWidget ) {
166
- timelineWidget . dispose ( ) ;
167
- timelineWidget = null ;
168
- }
161
+ if ( documentId && documentPath . split ( ':' ) [ 0 ] === 'RTC' ) {
162
+ if ( drive ) {
163
+ // Remove 'RTC:' from document path
164
+ documentPath = documentPath . slice ( drive . name . length + 1 ) ;
165
+ // Dispose of the previous timelineWidget if it exists
166
+ if ( timelineWidget ) {
167
+ timelineWidget . dispose ( ) ;
168
+ timelineWidget = null ;
169
+ }
169
170
170
- const [ format , type ] = documentId . split ( ':' ) ;
171
- const provider = drive . providers . get (
172
- `${ format } :${ type } :${ documentPath } `
173
- ) as unknown as IForkProvider ;
174
- const fullPath = URLExt . join (
175
- app . serviceManager . serverSettings . baseUrl ,
176
- DOCUMENT_TIMELINE_URL ,
177
- documentPath
178
- ) ;
171
+ const [ format , type ] = documentId . split ( ':' ) ;
172
+ const provider = drive . providers . get (
173
+ `${ format } :${ type } :${ documentPath } `
174
+ ) as unknown as IForkProvider ;
175
+ const fullPath = URLExt . join (
176
+ app . serviceManager . serverSettings . baseUrl ,
177
+ DOCUMENT_TIMELINE_URL ,
178
+ documentPath
179
+ ) ;
179
180
180
- timelineWidget = new TimelineWidget (
181
- fullPath ,
182
- provider ,
183
- provider . contentType ,
184
- provider . format
185
- ) ;
181
+ timelineWidget = new TimelineWidget (
182
+ fullPath ,
183
+ provider ,
184
+ provider . contentType ,
185
+ provider . format
186
+ ) ;
186
187
187
- const elt = document . getElementById ( 'jp-slider-status-bar' ) ;
188
- if ( elt && ! timelineWidget . isAttached ) {
189
- Widget . attach ( timelineWidget , elt ) ;
188
+ const elt = document . getElementById ( 'jp-slider-status-bar' ) ;
189
+ if ( elt && ! timelineWidget . isAttached ) {
190
+ Widget . attach ( timelineWidget , elt ) ;
191
+ }
190
192
}
191
193
}
192
194
} ;
@@ -222,8 +224,22 @@ export const statusBarTimeline: JupyterFrontEndPlugin<void> = {
222
224
align : 'left' ,
223
225
rank : 4 ,
224
226
isActive : ( ) => {
225
- const currentWidget = app . shell . currentWidget ;
226
- return ! ! currentWidget && 'context' in currentWidget ;
227
+ const currentWidget = app . shell
228
+ . currentWidget as DocumentWidget | null ;
229
+
230
+ if (
231
+ currentWidget &&
232
+ currentWidget . context &&
233
+ typeof currentWidget . context . path === 'string'
234
+ ) {
235
+ const documentPath = currentWidget . context . path ;
236
+ const documentId =
237
+ currentWidget . context . model . sharedModel . getState (
238
+ 'document_id'
239
+ ) as string ;
240
+ return ! ! documentId && documentPath . split ( ':' ) [ 0 ] === 'RTC' ;
241
+ }
242
+ return false ;
227
243
}
228
244
} ) ;
229
245
}
0 commit comments