mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-15 00:47:46 +01:00
components/app: make showNotification return null on error
We'll do more involved stuff with notifications soon, and don't want to deal with buggy notification objects.
This commit is contained in:
parent
bb42ff6a07
commit
7ddd783150
@ -120,7 +120,7 @@ function fillConnectParams(params) {
|
||||
|
||||
function showNotification(title, options) {
|
||||
if (!window.Notification || Notification.permission !== "granted") {
|
||||
return new EventTarget();
|
||||
return null;
|
||||
}
|
||||
|
||||
// This can still fail due to:
|
||||
@ -129,7 +129,7 @@ function showNotification(title, options) {
|
||||
return new Notification(title, options);
|
||||
} catch (err) {
|
||||
console.error("Failed to show notification: ", err);
|
||||
return new EventTarget();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,12 +524,14 @@ export default class App extends Component {
|
||||
requireInteraction: true,
|
||||
tag: "msg,server=" + serverID + ",from=" + msg.prefix.name + ",to=" + bufName,
|
||||
});
|
||||
if (notif) {
|
||||
notif.addEventListener("click", () => {
|
||||
// TODO: scroll to message
|
||||
this.switchBuffer({ server: serverID, name: bufName });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg.command === "INVITE" && client.isMyNick(msg.params[0])) {
|
||||
msgUnread = Unread.HIGHLIGHT;
|
||||
|
||||
@ -543,6 +545,7 @@ export default class App extends Component {
|
||||
title: "Accept",
|
||||
}],
|
||||
});
|
||||
if (notif) {
|
||||
notif.addEventListener("click", (event) => {
|
||||
if (event.action === "accept") {
|
||||
let stored = {
|
||||
@ -560,6 +563,7 @@ export default class App extends Component {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Open a new buffer if the message doesn't come from me or is a
|
||||
// self-message
|
||||
|
Loading…
x
Reference in New Issue
Block a user