@@ -218,7 +218,7 @@ async function searchPlugin() {
218218 $searchResult . onscroll = null ;
219219
220220 $searchResult . content = "" ;
221- const status = helpers . checkAPIStatus ( ) ;
221+ const status = await helpers . checkAPIStatus ( ) ;
222222 if ( ! status ) {
223223 $searchResult . content = (
224224 < span className = "error" > { strings . api_error } </ span >
@@ -409,7 +409,7 @@ async function loadInstalled() {
409409async function loadExplore ( ) {
410410 if ( this . collapsed ) return ;
411411
412- const status = helpers . checkAPIStatus ( ) ;
412+ const status = await helpers . checkAPIStatus ( ) ;
413413 if ( ! status ) {
414414 $explore . $ul . content = < span className = "error" > { strings . api_error } </ span > ;
415415 return ;
@@ -436,6 +436,7 @@ async function loadExplore() {
436436 currentPage ++ ;
437437 updateHeight ( $explore ) ;
438438 } catch ( error ) {
439+ console . error ( "Failed to load plugins in sidebar explore:" , error ) ;
439440 $explore . $ul . content = < span className = "error" > { strings . error } </ span > ;
440441 } finally {
441442 stopLoading ( $explore ) ;
@@ -446,15 +447,36 @@ async function listInstalledPlugins() {
446447 const plugins = await Promise . all (
447448 ( await fsOperation ( PLUGIN_DIR ) . lsDir ( ) ) . map ( async ( item ) => {
448449 const id = Url . basename ( item . url ) ;
449- const url = Url . join ( item . url , "plugin.json" ) ;
450- const plugin = await fsOperation ( url ) . readFile ( "json" ) ;
451- const iconUrl = getLocalRes ( id , plugin . icon ) ;
452- plugin . icon = await helpers . toInternalUri ( iconUrl ) ;
453- plugin . installed = true ;
454- return plugin ;
450+
451+ try {
452+ const url = Url . join ( item . url , "plugin.json" ) ;
453+ const plugin = await fsOperation ( url ) . readFile ( "json" ) ;
454+
455+ if ( plugin . icon ) {
456+ const iconUrl = getLocalRes ( id , plugin . icon ) ;
457+ try {
458+ plugin . icon = await helpers . toInternalUri ( iconUrl ) ;
459+ } catch ( error ) {
460+ console . warn (
461+ `Failed to resolve plugin icon for "${ id } " in sidebar.` ,
462+ error ,
463+ ) ;
464+ }
465+ }
466+
467+ plugin . installed = true ;
468+ return plugin ;
469+ } catch ( error ) {
470+ console . warn (
471+ `Skipping unreadable installed plugin "${ id } " in sidebar.` ,
472+ error ,
473+ ) ;
474+ return null ;
475+ }
455476 } ) ,
456477 ) ;
457- return plugins ;
478+
479+ return plugins . filter ( Boolean ) ;
458480}
459481
460482async function getFilteredPlugins ( filterState ) {
0 commit comments