Skip to content

Commit

Permalink
Update window handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SRichner committed Feb 21, 2024
1 parent 6de1e50 commit d0ef026
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
39 changes: 0 additions & 39 deletions src/electron/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,6 @@ log.initialize();
const LOG = getLogger('Main', true);
LOG.info('Log from the main process');

let win: BrowserWindow | null = null;
const preload = join(__dirname, '../preload/index.mjs');
const url = process.env.VITE_DEV_SERVER_URL;
const indexHtml = join(process.env.DIST, 'index.html');

async function createWindow() {
win = new BrowserWindow({
title: 'Main window',
icon: join(process.env.VITE_PUBLIC, 'favicon.ico'),
webPreferences: {
preload
}
});

if (process.env.VITE_DEV_SERVER_URL) {
// electron-vite-vue#298
win.loadURL(url);
win.webContents.openDevTools();
} else {
win.loadFile(indexHtml);
}
}

app.whenReady().then(async () => {
app.setAppUserModelId('ch.ifi.hasel.personal-analytics');

Expand Down Expand Up @@ -136,19 +113,3 @@ app.whenReady().then(async () => {
);
}
});

app.on('window-all-closed', () => {
win = null;
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
const allWindows = BrowserWindow.getAllWindows();
if (allWindows.length) {
allWindows[0].focus();
} else {
createWindow();
}
});
1 change: 1 addition & 0 deletions src/electron/electron/main/services/WindowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class WindowService {

public async createExperienceSamplingWindow() {
this.experienceSamplingWindow?.close();
this.experienceSamplingWindow = null;

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down

0 comments on commit d0ef026

Please sign in to comment.