-
-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathnotification.js
More file actions
54 lines (54 loc) · 1.85 KB
/
notification.js
File metadata and controls
54 lines (54 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use strict";
const electron_1 = require("electron");
const notifications = (global["notifications"] =
global["notifications"] || []);
let electronSocket;
module.exports = (socket) => {
electronSocket = socket;
socket.on("createNotification", (options) => {
const notification = new electron_1.Notification(options);
let haveEvent = false;
if (options.showID) {
haveEvent = true;
notification.on("show", () => {
electronSocket.emit("NotificationEventShow", options.showID);
});
}
if (options.clickID) {
haveEvent = true;
notification.on("click", () => {
electronSocket.emit("NotificationEventClick", options.clickID);
});
}
if (options.closeID) {
haveEvent = true;
notification.on("close", () => {
electronSocket.emit("NotificationEventClose", options.closeID);
});
}
if (options.replyID) {
haveEvent = true;
notification.on("reply", (event, value) => {
electronSocket.emit("NotificationEventReply", [options.replyID, value]);
});
}
if (options.actionID) {
haveEvent = true;
notification.on("action", (event, value) => {
electronSocket.emit("NotificationEventAction", [
options.actionID,
value,
]);
});
}
if (haveEvent) {
notifications.push(notification);
}
notification.show();
});
socket.on("notificationIsSupported", () => {
const isSupported = electron_1.Notification.isSupported();
electronSocket.emit("notificationIsSupportedCompleted", isSupported);
});
};
//# sourceMappingURL=notification.js.map