Skip to content

Commit ce149eb

Browse files
committed
fix: use optional chaining for isDestroyed() checks
1 parent b58442f commit ce149eb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/node/services/ipcMain.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class IpcMain {
228228
workspaceId: string,
229229
snapshot: WorkspaceActivitySnapshot | null
230230
): void {
231-
if (!this.mainWindow || this.mainWindow.isDestroyed()) {
231+
if (!this.mainWindow || this.mainWindow?.isDestroyed()) {
232232
return;
233233
}
234234
this.mainWindow.webContents.send(IPC_CHANNELS.WORKSPACE_ACTIVITY, {
@@ -508,15 +508,15 @@ export class IpcMain {
508508
});
509509

510510
const chatUnsubscribe = session.onChatEvent((event) => {
511-
if (!this.mainWindow || this.mainWindow.isDestroyed()) {
511+
if (!this.mainWindow || this.mainWindow?.isDestroyed()) {
512512
return;
513513
}
514514
const channel = getChatChannel(event.workspaceId);
515515
this.mainWindow.webContents.send(channel, event.message);
516516
});
517517

518518
const metadataUnsubscribe = session.onMetadataEvent((event) => {
519-
if (!this.mainWindow || this.mainWindow.isDestroyed()) {
519+
if (!this.mainWindow || this.mainWindow?.isDestroyed()) {
520520
return;
521521
}
522522
this.mainWindow.webContents.send(IPC_CHANNELS.WORKSPACE_METADATA, {
@@ -969,7 +969,7 @@ export class IpcMain {
969969
const session = this.sessions.get(workspaceId);
970970
if (session) {
971971
session.emitMetadata(updatedMetadata);
972-
} else if (this.mainWindow && !this.mainWindow.isDestroyed()) {
972+
} else if (this.mainWindow && !this.mainWindow?.isDestroyed()) {
973973
this.mainWindow.webContents.send(IPC_CHANNELS.WORKSPACE_METADATA, {
974974
workspaceId,
975975
metadata: updatedMetadata,
@@ -1379,7 +1379,7 @@ export class IpcMain {
13791379
type: "delete",
13801380
historySequences: deletedSequences,
13811381
};
1382-
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
1382+
if (this.mainWindow && !this.mainWindow?.isDestroyed()) {
13831383
this.mainWindow.webContents.send(getChatChannel(workspaceId), deleteMessage);
13841384
}
13851385
}
@@ -1419,7 +1419,7 @@ export class IpcMain {
14191419
}
14201420

14211421
// Send delete event to frontend for all old messages
1422-
if (deletedSequences.length > 0 && this.mainWindow && !this.mainWindow.isDestroyed()) {
1422+
if (deletedSequences.length > 0 && this.mainWindow && !this.mainWindow?.isDestroyed()) {
14231423
const deleteMessage: DeleteMessage = {
14241424
type: "delete",
14251425
historySequences: deletedSequences,
@@ -1428,7 +1428,7 @@ export class IpcMain {
14281428
}
14291429

14301430
// Send the new summary message to frontend
1431-
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
1431+
if (this.mainWindow && !this.mainWindow?.isDestroyed()) {
14321432
this.mainWindow.webContents.send(getChatChannel(workspaceId), summaryMessage);
14331433
}
14341434

@@ -1634,7 +1634,7 @@ export class IpcMain {
16341634
const existingSession = this.sessions.get(workspaceId);
16351635
if (existingSession) {
16361636
existingSession.emitMetadata(null);
1637-
} else if (this.mainWindow && !this.mainWindow.isDestroyed()) {
1637+
} else if (this.mainWindow && !this.mainWindow?.isDestroyed()) {
16381638
this.mainWindow.webContents.send(IPC_CHANNELS.WORKSPACE_METADATA, {
16391639
workspaceId,
16401640
metadata: null,
@@ -2093,7 +2093,7 @@ export class IpcMain {
20932093
const chatChannel = getChatChannel(workspaceId);
20942094

20952095
await session.replayHistory((event) => {
2096-
if (!this.mainWindow || this.mainWindow.isDestroyed()) {
2096+
if (!this.mainWindow || this.mainWindow?.isDestroyed()) {
20972097
return;
20982098
}
20992099
this.mainWindow.webContents.send(chatChannel, event.message);

0 commit comments

Comments
 (0)