File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 1616 }
1717
1818 function storeConfigToLocalStorage ( data ) {
19- chrome . storage . local . set ( { [ SETUP_STRING ] : data || { } } ) ;
19+ // return promise
20+ return chrome . storage . local . set ( { [ SETUP_STRING ] : data || { } } )
2021 }
2122
2223 function getConfigFromLocalStorage ( ) {
3536 sendMsgToAllContainPage ( 'live-server-config-updated' , msg . data ) ;
3637 }
3738 else if ( msg . req === 'get-live-server-config' ) {
38- getConfigFromLocalStorage ( ) . then (
39- function ( value ) { sendResponse ( value ) } ,
40- function ( error ) { console . error ( `Error: ${ error } ` ) }
41- ) ;
39+ getConfigFromLocalStorage ( )
40+ . then ( function ( value ) {
41+ sendResponse ( value )
42+ } )
43+ . catch ( function ( error ) {
44+ console . error ( "Error in get-live-server-config:" , error ) ;
45+ sendResponse ( { } )
46+ } ) ;
4247 }
4348 return true ; //Keep the callback(sendResponse) active
4449 } ) ;
Original file line number Diff line number Diff line change 1818 liveServerUrl : liveServerAddress . value || ''
1919 }
2020
21- if ( chrome && chrome . runtime ) {
22- chrome . runtime . sendMessage ( {
23- req : 'set-live-server-config' ,
24- data : formData
25- } ) ;
26- }
21+ chrome . runtime . sendMessage ( {
22+ req : 'set-live-server-config' ,
23+ data : formData
24+ } ) ;
25+
2726 }
2827
2928 liveReloadCheck . onclick = ( ) => {
4140 chrome . runtime . sendMessage ( {
4241 req : 'get-live-server-config'
4342 } , ( data ) => {
44- if ( data ) {
45- liveReloadCheck . checked = data . isEnable || false ;
46- noProxyCheckBox . checked = ! data . proxySetup ;
47- actualServerAddress . value = data . actualUrl || '' ;
48- liveServerAddress . value = data . liveServerUrl || '' ;
49- serverSetupDiv . className = noProxyCheckBox . checked ? 'show' : 'hide' ;
50- }
43+ if ( ! data ) return
44+ liveReloadCheck . checked = data . isEnable || false ;
45+ noProxyCheckBox . checked = ! data . proxySetup ;
46+ actualServerAddress . value = data . actualUrl || '' ;
47+ liveServerAddress . value = data . liveServerUrl || '' ;
48+ serverSetupDiv . className = noProxyCheckBox . checked ? 'show' : 'hide' ;
5149 } ) ;
5250 } ) ;
5351
6260 submitBtn . classList . add ( 'btn-highlight' ) ;
6361 }
6462
65-
6663} ) ( ) ;
You can’t perform that action at this time.
0 commit comments