Don't show notification if window is focused

This commit is contained in:
miruka
2020-09-16 11:31:34 -04:00
parent a8a25d09ee
commit dcc3473ecf
3 changed files with 22 additions and 17 deletions

View File

@@ -11,15 +11,17 @@ QtObject {
Qt.exit(exitCode)
}
function onAlertRequested(highImportance) {
function onNotificationRequested(title, body, image, highImportance) {
if (Qt.application.state === Qt.ApplicationActive) return
py.callCoro("desktop_notify", [title, body, image])
const msec =
highImportance ?
window.settings.alertOnMentionForMsec :
window.settings.alertOnMessageForMsec
if (Qt.application.state !== Qt.ApplicationActive && msec !== 0) {
window.alert(msec === -1 ? 0 : msec) // -1 → 0 = no time out
}
if (msec) window.alert(msec === -1 ? 0 : msec) // -1 → 0 = no time out
}
function onCoroutineDone(uuid, result, error, traceback) {