mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
components/app: close notifications when switching buffer
This commit is contained in:
parent
7ddd783150
commit
7c6f334dbf
1 changed files with 14 additions and 1 deletions
|
@ -201,6 +201,7 @@ export default class App extends Component {
|
|||
* confirmation for security reasons.
|
||||
*/
|
||||
autoOpenURL = null;
|
||||
messageNotifications = new Set();
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -450,8 +451,15 @@ export default class App extends Component {
|
|||
this.buffer.current.focus();
|
||||
}
|
||||
|
||||
let client = this.clients.get(buf.server);
|
||||
|
||||
for (let notif of this.messageNotifications) {
|
||||
if (client.cm(notif.data.bufferName) === client.cm(buf.name)) {
|
||||
notif.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (buf.messages.length > 0) {
|
||||
let client = this.clients.get(buf.server);
|
||||
let lastMsg = buf.messages[buf.messages.length - 1];
|
||||
let stored = {
|
||||
name: buf.name,
|
||||
|
@ -523,12 +531,17 @@ export default class App extends Component {
|
|||
body: stripANSI(text),
|
||||
requireInteraction: true,
|
||||
tag: "msg,server=" + serverID + ",from=" + msg.prefix.name + ",to=" + bufName,
|
||||
data: { bufferName: bufName, message: msg },
|
||||
});
|
||||
if (notif) {
|
||||
notif.addEventListener("click", () => {
|
||||
// TODO: scroll to message
|
||||
this.switchBuffer({ server: serverID, name: bufName });
|
||||
});
|
||||
notif.addEventListener("close", () => {
|
||||
this.messageNotifications.delete(notif);
|
||||
});
|
||||
this.messageNotifications.add(notif);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue