Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
const indexPath = path.join(__dirname, "../dist/index.html")
console.log("Falling back to:", indexPath)
if (fs.existsSync(indexPath)) {
state.mainWindow.loadFile(indexPath)

Check failure on line 272 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 272 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
} else {
console.error("Could not find index.html in dist folder")
}
Expand All @@ -293,11 +293,19 @@
}
state.mainWindow.webContents.setWindowOpenHandler(({ url }) => {
console.log("Attempting to open URL:", url)
if (url.includes("google.com") || url.includes("supabase.co")) {
shell.openExternal(url)
return { action: "deny" }
try {
const parsedURL = new URL(url);
const hostname = parsedURL.hostname;
const allowedHosts = ["google.com", "supabase.co"];
if (allowedHosts.includes(hostname) || hostname.endsWith(".google.com") || hostname.endsWith(".supabase.co")) {
shell.openExternal(url);
return { action: "deny" }; // Do not open this URL in a new Electron window
}
} catch (error) {
console.error("Invalid URL %d in setWindowOpenHandler: %d" , url , error);
return { action: "deny" }; // Deny access as URL string is malformed or invalid
}
return { action: "allow" }
return { action: "allow" };
})

// Enhanced screen capture resistance
Expand Down Expand Up @@ -382,11 +390,11 @@
// Window visibility functions
function hideMainWindow(): void {
if (!state.mainWindow?.isDestroyed()) {
const bounds = state.mainWindow.getBounds();

Check failure on line 393 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 393 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.windowPosition = { x: bounds.x, y: bounds.y };
state.windowSize = { width: bounds.width, height: bounds.height };
state.mainWindow.setIgnoreMouseEvents(true, { forward: true });

Check failure on line 396 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 396 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.mainWindow.setOpacity(0);

Check failure on line 397 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 397 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.isWindowVisible = false;
console.log('Window hidden, opacity set to 0');
}
Expand All @@ -395,17 +403,17 @@
function showMainWindow(): void {
if (!state.mainWindow?.isDestroyed()) {
if (state.windowPosition && state.windowSize) {
state.mainWindow.setBounds({

Check failure on line 406 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 406 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
...state.windowPosition,
...state.windowSize
});
}
state.mainWindow.setIgnoreMouseEvents(false);

Check failure on line 411 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 411 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.mainWindow.setAlwaysOnTop(true, "screen-saver", 1);

Check failure on line 412 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 412 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.mainWindow.setVisibleOnAllWorkspaces(true, {

Check failure on line 413 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 413 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
visibleOnFullScreen: true
});
state.mainWindow.setContentProtection(true);

Check failure on line 416 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'state.mainWindow' is possibly 'null'.

Check failure on line 416 in electron/main.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'state.mainWindow' is possibly 'null'.
state.mainWindow.setOpacity(0); // Set opacity to 0 before showing
state.mainWindow.showInactive(); // Use showInactive instead of show+focus
state.mainWindow.setOpacity(1); // Then set opacity to 1 after showing
Expand Down
Loading