mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -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.
|
* confirmation for security reasons.
|
||||||
*/
|
*/
|
||||||
autoOpenURL = null;
|
autoOpenURL = null;
|
||||||
|
messageNotifications = new Set();
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -450,8 +451,15 @@ export default class App extends Component {
|
||||||
this.buffer.current.focus();
|
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) {
|
if (buf.messages.length > 0) {
|
||||||
let client = this.clients.get(buf.server);
|
|
||||||
let lastMsg = buf.messages[buf.messages.length - 1];
|
let lastMsg = buf.messages[buf.messages.length - 1];
|
||||||
let stored = {
|
let stored = {
|
||||||
name: buf.name,
|
name: buf.name,
|
||||||
|
@ -523,12 +531,17 @@ export default class App extends Component {
|
||||||
body: stripANSI(text),
|
body: stripANSI(text),
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
tag: "msg,server=" + serverID + ",from=" + msg.prefix.name + ",to=" + bufName,
|
tag: "msg,server=" + serverID + ",from=" + msg.prefix.name + ",to=" + bufName,
|
||||||
|
data: { bufferName: bufName, message: msg },
|
||||||
});
|
});
|
||||||
if (notif) {
|
if (notif) {
|
||||||
notif.addEventListener("click", () => {
|
notif.addEventListener("click", () => {
|
||||||
// TODO: scroll to message
|
// TODO: scroll to message
|
||||||
this.switchBuffer({ server: serverID, name: bufName });
|
this.switchBuffer({ server: serverID, name: bufName });
|
||||||
});
|
});
|
||||||
|
notif.addEventListener("close", () => {
|
||||||
|
this.messageNotifications.delete(notif);
|
||||||
|
});
|
||||||
|
this.messageNotifications.add(notif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue