@@ -87,11 +87,12 @@ export class ResourcesActionsIpc implements TIpcHandlerInterface {
8787 const resources = await this . getResources ( ) ;
8888
8989 if ( resources !== undefined ) {
90- this . updateTrayMenu ( resources . items ) ;
90+ this . updateTrayMenu ( resources ) ;
91+ updateResourceWindow . hide ( ) ;
92+ ipcWebContentsSend ( "resources" , mainWindow . webContents , {
93+ items : resources ,
94+ } ) ;
9195 }
92-
93- updateResourceWindow . hide ( ) ;
94- ipcWebContentsSend ( "resources" , mainWindow . webContents , resources ) ;
9596 }
9697
9798 return undefined ;
@@ -133,11 +134,12 @@ export class ResourcesActionsIpc implements TIpcHandlerInterface {
133134 const resources = await this . getResources ( ) ;
134135
135136 if ( resources !== undefined ) {
136- this . updateTrayMenu ( resources . items ) ;
137+ this . updateTrayMenu ( resources ) ;
138+ addResourceWindow . hide ( ) ;
139+ ipcWebContentsSend ( "resources" , mainWindow . webContents , {
140+ items : resources ,
141+ } ) ;
137142 }
138-
139- addResourceWindow . hide ( ) ;
140- ipcWebContentsSend ( "resources" , mainWindow . webContents , resources ) ;
141143 }
142144
143145 return undefined ;
@@ -190,26 +192,27 @@ export class ResourcesActionsIpc implements TIpcHandlerInterface {
190192
191193 const resources = await this . getResources ( ) ;
192194 if ( resources !== undefined ) {
193- this . updateTrayMenu ( resources . items ) ;
195+ this . updateTrayMenu ( resources ) ;
196+ event . reply ( "resources" , {
197+ items : resources ,
198+ } ) ;
194199 }
195200
196- event . reply ( "resources" , resources ) ;
197-
198201 ipcWebContentsSend ( "sync" , mainWindow . webContents , {
199202 isResources : true ,
200203 } ) ;
201204 }
202205 } ) ;
203206 }
204207
205- private async getResources ( ) : Promise < {
206- items : TResource [ ] ;
207- } > {
208+ private async getResources ( ) : Promise < TResource [ ] | undefined > {
208209 const resources = await this . resourcesService . list ( ) ;
209210
210- return {
211- items : resources || [ ] ,
212- } ;
211+ if ( resources === undefined ) {
212+ return ;
213+ }
214+
215+ return resources ;
213216 }
214217
215218 private ipcDeleteResource ( mainWindow : BrowserWindow | undefined ) : void {
@@ -229,11 +232,12 @@ export class ResourcesActionsIpc implements TIpcHandlerInterface {
229232 const resources = await this . getResources ( ) ;
230233
231234 if ( resources !== undefined ) {
232- this . updateTrayMenu ( resources . items ) ;
235+ this . updateTrayMenu ( resources ) ;
236+ deleteResourceWindow . hide ( ) ;
237+ ipcWebContentsSend ( "resources" , mainWindow . webContents , {
238+ items : resources ,
239+ } ) ;
233240 }
234-
235- deleteResourceWindow . hide ( ) ;
236- ipcWebContentsSend ( "resources" , mainWindow . webContents , resources ) ;
237241 }
238242
239243 return undefined ;
0 commit comments