Skip to content

Commit 8b2a865

Browse files
committed
pass the protocol in the package.json in build section
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.
1 parent 5b5c380 commit 8b2a865

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

app/renderer/js/electron-bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ElectronBridge = {
1717
title: string,
1818
options: NotificationOptions,
1919
dispatch: (type: string, eventInit: EventInit) => boolean,
20-
) => NotificationData | null;
20+
) => NotificationData;
2121
get_idle_on_system: () => boolean;
2222
get_last_active_on_system: () => number;
2323
get_send_notification_reply_message_supported: () => boolean;
@@ -47,7 +47,7 @@ const electron_bridge: ElectronBridge = {
4747
title: string,
4848
options: NotificationOptions,
4949
dispatch: (type: string, eventInit: EventInit) => boolean,
50-
): NotificationData | null => newNotification(title, options, dispatch),
50+
): NotificationData => newNotification(title, options, dispatch),
5151

5252
get_idle_on_system: (): boolean => idle,
5353

app/renderer/js/notification/index.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
import {powerMonitor} from "electron/main";
2-
31
import {ipcRenderer} from "../typed-ipc-renderer.js";
42

5-
let isLocked = false;
6-
7-
powerMonitor.on("lock-screen", () => {
8-
isLocked = true;
9-
});
10-
powerMonitor.on("unlock-screen", () => {
11-
isLocked = false;
12-
});
13-
143
export type NotificationData = {
154
close: () => void;
165
title: string;
@@ -26,12 +15,7 @@ export function newNotification(
2615
title: string,
2716
options: NotificationOptions,
2817
dispatch: (type: string, eventInit: EventInit) => boolean,
29-
): NotificationData | null {
30-
if (isLocked) {
31-
console.log("Notification blocked: Screen is locked.");
32-
return null; // Prevent showing notification when the screen is locked
33-
}
34-
18+
): NotificationData {
3519
const notification = new Notification(title, {...options, silent: true});
3620
for (const type of ["click", "close", "error", "show"]) {
3721
notification.addEventListener(type, (event) => {

0 commit comments

Comments
 (0)