Skip to content

Commit

Permalink
pass the protocol in the package.json in build section
Browse files Browse the repository at this point in the history
To register a custom protocol for your Electron application across all platforms (Windows, macOS, and Linux), you can define it in the build section of your package.json file using the protocols property provided by electron-builder.
  • Loading branch information
avijitdas126 committed Feb 22, 2025
1 parent 5b5c380 commit 8b2a865
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/renderer/js/electron-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type ElectronBridge = {
title: string,
options: NotificationOptions,
dispatch: (type: string, eventInit: EventInit) => boolean,
) => NotificationData | null;
) => NotificationData;
get_idle_on_system: () => boolean;
get_last_active_on_system: () => number;
get_send_notification_reply_message_supported: () => boolean;
Expand Down Expand Up @@ -47,7 +47,7 @@ const electron_bridge: ElectronBridge = {
title: string,
options: NotificationOptions,
dispatch: (type: string, eventInit: EventInit) => boolean,
): NotificationData | null => newNotification(title, options, dispatch),
): NotificationData => newNotification(title, options, dispatch),

get_idle_on_system: (): boolean => idle,

Expand Down
18 changes: 1 addition & 17 deletions app/renderer/js/notification/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import {powerMonitor} from "electron/main";

import {ipcRenderer} from "../typed-ipc-renderer.js";

let isLocked = false;

powerMonitor.on("lock-screen", () => {
isLocked = true;
});
powerMonitor.on("unlock-screen", () => {
isLocked = false;
});

export type NotificationData = {
close: () => void;
title: string;
Expand All @@ -26,12 +15,7 @@ export function newNotification(
title: string,
options: NotificationOptions,
dispatch: (type: string, eventInit: EventInit) => boolean,
): NotificationData | null {
if (isLocked) {
console.log("Notification blocked: Screen is locked.");
return null; // Prevent showing notification when the screen is locked
}

): NotificationData {
const notification = new Notification(title, {...options, silent: true});
for (const type of ["click", "close", "error", "show"]) {
notification.addEventListener(type, (event) => {
Expand Down

0 comments on commit 8b2a865

Please sign in to comment.