Skip to content

Commit

Permalink
feat: clarify its the main window; debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
KatoakDR committed Dec 31, 2023
1 parent 663d1ff commit 6de0ecb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions electron/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (appEnvIsProd) {

let ipcController: IpcController;

const createWindow = async (): Promise<void> => {
const createMainWindow = async (): Promise<void> => {
if (appEnvIsDev) {
// If running in development, serve the renderer from localhost.
// This must be done once the app is ready.
Expand Down Expand Up @@ -86,7 +86,7 @@ const createWindow = async (): Promise<void> => {

// Once the window has finished loading, show it.
mainWindow.webContents.once('did-finish-load', () => {
logger.info('showing window');
logger.info('showing main window');
mainWindow.show();
});

Expand All @@ -101,6 +101,7 @@ const createWindow = async (): Promise<void> => {

ipcController = newIpcController({ dispatch });

logger.info('loading main window', { appUrl });
await mainWindow.loadURL(appUrl);

initializeMenu(mainWindow);
Expand All @@ -109,7 +110,7 @@ const createWindow = async (): Promise<void> => {
// Prepare the renderer once the app is ready
app.on('ready', () => {
runInBackground(async () => {
await createWindow();
await createMainWindow();
});
});

Expand Down Expand Up @@ -155,6 +156,7 @@ app.on('web-contents-created', (_, contents) => {
});

app.on('window-all-closed', (): void => {
logger.debug('windows all closed, quitting app');
app.quit();
});

Expand All @@ -177,6 +179,7 @@ app.on('before-quit', (event: Event): void => {
event.preventDefault();
beforeQuitActionStatus = BeforeQuitActionStatus.IN_PROGRESS;
runInBackground(async () => {
logger.debug('performing before-quit operations');
await ipcController?.destroy();
beforeQuitActionStatus = BeforeQuitActionStatus.COMPLETED;
app.quit();
Expand All @@ -193,5 +196,6 @@ app.on('before-quit', (event: Event): void => {
});

app.on('quit', (): void => {
logger.debug('quitting app');
logger.info('until next time, brave adventurer');
});

0 comments on commit 6de0ecb

Please sign in to comment.