Skip to content

Commit 05d443b

Browse files
committed
maint(pat push): Fetch desktop notification data only when desktop notifications are allowed.
1 parent c702833 commit 05d443b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/pat/push/push.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ export default Base.extend({
5151

5252
async desktop_notification() {
5353
try {
54-
const response = await fetch(this.options.url);
55-
const data = await response.json();
56-
57-
if (data.length === 0) {
58-
return;
59-
}
60-
6154
// Let's check if the browser supports notifications
6255
if (!("Notification" in window)) {
6356
logger.error("This browser does not support notifications.");
@@ -79,6 +72,13 @@ export default Base.extend({
7972

8073
// Let's check if the user is okay to get some notification
8174
if (Notification.permission === "granted") {
75+
const response = await fetch(this.options.url);
76+
const data = await response.json();
77+
78+
if (data.length === 0) {
79+
return;
80+
}
81+
8282
for (const message of data) {
8383
new Notification(message.title, message);
8484
}

0 commit comments

Comments
 (0)