File tree Expand file tree Collapse file tree 2 files changed +208
-153
lines changed Expand file tree Collapse file tree 2 files changed +208
-153
lines changed Original file line number Diff line number Diff line change @@ -189,29 +189,18 @@ export class DeepnoteNotebookSerializer implements NotebookSerializer {
189189 * @returns
190190 */
191191 private findDefaultNotebook ( file : DeepnoteFile ) : DeepnoteNotebook | undefined {
192- const sortedNotebooks = file . project . notebooks . slice ( ) . sort ( ( a , b ) => {
193- const nameA = a . name . toLowerCase ( ) ;
194- const nameB = b . name . toLowerCase ( ) ;
195-
196- // If there's an Init notebook, we don't want to open it by default unless it's the only one.
197- if ( file . project . initNotebookId && a . id === file . project . initNotebookId ) {
198- return 1 ;
199- }
200-
201- if ( file . project . initNotebookId && b . id === file . project . initNotebookId ) {
202- return - 1 ;
203- }
204-
205- if ( nameA < nameB ) {
206- return - 1 ;
207- }
192+ if ( file . project . notebooks . length === 0 ) {
193+ return undefined ;
194+ }
208195
209- if ( nameA > nameB ) {
210- return 1 ;
211- }
196+ const sortedNotebooks = file . project . notebooks . slice ( ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
197+ const sortedNotebooksWithoutInit = file . project . initNotebookId
198+ ? sortedNotebooks . filter ( ( nb ) => nb . id !== file . project . initNotebookId )
199+ : sortedNotebooks ;
212200
213- return 0 ;
214- } ) ;
201+ if ( sortedNotebooksWithoutInit . length > 0 ) {
202+ return sortedNotebooksWithoutInit [ 0 ] ;
203+ }
215204
216205 return sortedNotebooks [ 0 ] ;
217206 }
You can’t perform that action at this time.
0 commit comments