11import React , { useEffect , useState } from 'react' ;
22import { IDocumentManager } from '@jupyterlab/docmanager' ;
3- import { IDocumentWidget } from '@jupyterlab/docregistry ' ;
4- import { JupyterFrontEnd , LabShell } from '@jupyterlab/application' ;
3+ import { Notification } from '@jupyterlab/apputils ' ;
4+ import { JupyterFrontEnd } from '@jupyterlab/application' ;
55import { getProfile } from '../services/leetcode' ;
66import { LeetCodeProfile } from '../types/leetcode' ;
77import Profile from './Profile' ;
88import Statistics from './Statistics' ;
99import QuestionList from './QuestionList' ;
1010
11- export function getCurrentOpenFilePath (
12- shell : LabShell ,
13- docManager : IDocumentManager ,
14- widget ?: IDocumentWidget
15- ) : string | null {
16- const currentWidget = widget ?? shell . currentWidget ;
17- if ( ! currentWidget || ! docManager ) {
18- return null ;
19- }
20- const context = docManager . contextForWidget ( currentWidget ) ;
21- if ( ! context ) {
22- return null ;
23- }
24- return context . path ;
25- }
26-
2711const LeetCode : React . FC < {
2812 app : JupyterFrontEnd ;
2913 docManager : IDocumentManager ;
@@ -34,12 +18,14 @@ const LeetCode: React.FC<{
3418 getProfile ( )
3519 . then ( profile => {
3620 if ( ! profile . isSignedIn ) {
37- alert ( 'Please sign in to LeetCode.' ) ;
21+ Notification . error ( 'Please sign in to LeetCode.' , {
22+ autoClose : 3000
23+ } ) ;
3824 return ;
3925 }
4026 setProfile ( profile ) ;
4127 } )
42- . catch ( console . error ) ;
28+ . catch ( e => Notification . error ( e . message , { autoClose : 3000 } ) ) ;
4329 } , [ ] ) ;
4430
4531 const openNoteBook = ( path : string ) => {
0 commit comments