@@ -113,7 +113,16 @@ export class ComponentsPacksWebviewMain {
113113 private async handleWebviewCommand ( treeNode : COutlineItem | undefined ) {
114114 if ( treeNode ) {
115115 await this . openWebview ( treeNode . cprojectPath , treeNode . clayerPath ) ;
116+ return ;
117+ }
118+
119+ const projectId = this . getValidProjectId ( ) ;
120+ if ( ! projectId ) {
121+ this . messageProvider . showWarningMessage ( 'No valid project found in the active solution.' ) ;
122+ return ;
116123 }
124+
125+ await this . openWebview ( projectId , undefined ) ;
117126 }
118127
119128 private projectFromPath ( path : string | undefined ) : string {
@@ -131,7 +140,8 @@ export class ComponentsPacksWebviewMain {
131140 return ; // nothing to show
132141 }
133142
134- const reload = this . projectFromPath ( this . currentProject ?. project . projectId ) !== this . projectFromPath ( cprojectPath ) ;
143+ const reload = this . currentProject === undefined ||
144+ this . projectFromPath ( this . currentProject . project . projectId ) !== this . projectFromPath ( cprojectPath ) ;
135145 const csolution = this . solutionManager . getCsolution ( ) ;
136146 if ( csolution ) {
137147 this . currentProject = { solutionPath : csolution . solutionPath , project : createProject ( cprojectPath ) } ;
@@ -217,7 +227,7 @@ export class ComponentsPacksWebviewMain {
217227 }
218228
219229 const latestUsedItems = usedItems ?? await this . csolutionService . getUsedItems ( { context : actx } ) ;
220- if ( this . usedItems ?. packs . length !== latestUsedItems . packs . length || this . usedItems ?. components . length !== latestUsedItems . components . length ) {
230+ if ( this . usedItems ?. packs ? .length !== latestUsedItems . packs ? .length || this . usedItems ?. components ? .length !== latestUsedItems . components ? .length ) {
221231 return true ;
222232 }
223233
@@ -228,8 +238,8 @@ export class ComponentsPacksWebviewMain {
228238 packs : [ ...( this . usedItems ?. packs ?? [ ] ) ] . sort ( ( a , b ) => a . pack . localeCompare ( b . pack ) ) . map ( packMapper ) ,
229239 } ;
230240 const usedItemsSorted = {
231- components : [ ...latestUsedItems . components ] . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) . map ( componentMapper ) ,
232- packs : [ ...latestUsedItems . packs ] . sort ( ( a , b ) => a . pack . localeCompare ( b . pack ) ) . map ( packMapper ) ,
241+ components : [ ...( latestUsedItems . components ?? [ ] ) ] . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) . map ( componentMapper ) ,
242+ packs : [ ...( latestUsedItems . packs ?? [ ] ) ] . sort ( ( a , b ) => a . pack . localeCompare ( b . pack ) ) . map ( packMapper ) ,
233243 } ;
234244 const usedItemsChanged = ! isDeepStrictEqual ( localUsedItemsSorted , usedItemsSorted ) ;
235245 return usedItemsChanged ;
0 commit comments