Skip to content

Commit 2bbfddd

Browse files
committed
it doesn't clear resources and user from cache if there is not 401
1 parent 4a06181 commit 2bbfddd

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "electron-gp",
33
"private": true,
4-
"version": "0.2.16",
4+
"version": "0.2.17",
55
"type": "module",
66
"main": "dist-main/app.js",
77
"author": "traeop",

src/main/resources/ipc/actions.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/main/user/ipc.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ export class UserIpc {
2727
}
2828

2929
const user = userId ? await this.userService.byId(userId) : undefined;
30-
event.reply("checkUser", {
31-
user,
32-
});
30+
if (user !== undefined) {
31+
event.reply("checkUser", {
32+
user,
33+
});
34+
}
3335

3436
ipcWebContentsSend("sync", mainWindow.webContents, {
3537
isUser: true,

0 commit comments

Comments
 (0)