0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 18:03:53 +01:00

go back to the original behaviour of only notifying if we think the app is backgrounded or idle...

This commit is contained in:
Matthew Hodgson 2014-09-20 01:40:29 +01:00
parent 4c7a1abd39
commit a0c3da17b4

View file

@ -190,20 +190,26 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
if (window.Notification && event.user_id != matrixService.config().user_id) { if (window.Notification && event.user_id != matrixService.config().user_id) {
var shouldBing = $rootScope.containsBingWord(event.content.body); var shouldBing = $rootScope.containsBingWord(event.content.body);
// TODO: Binging every message when idle doesn't make much sense. Can we use this more sensibly? // Ideally we would notify only when the window is hidden (i.e. document.hidden = true).
// Unfortunately document.hidden = false on ubuntu chrome if chrome is minimised / does not have focus; //
// true when you swap tabs though. However, for the case where the chat screen is OPEN and there is // However, Chrome on Linux and OSX currently returns document.hidden = false unless the window is
// another window on top, we want to be notifying for those events. This DOES mean that there will be // explicitly showing a different tab. So we need another metric to determine hiddenness - we
// notifications when currently viewing the chat screen though, but that is preferable to the alternative imo. // simply use idle time. If the user has been idle enough that their presence goes to idle, then
// we also display notifs when things happen.
//
// This is far far better than notifying whenever anything happens anyway, otherwise you get spammed
// to death with notifications when the window is in the foreground, which is horrible UX (especially
// if you have not defined any bingers and so get notified for everything).
var isIdle = (document.hidden || matrixService.presence.unavailable === mPresence.getState()); var isIdle = (document.hidden || matrixService.presence.unavailable === mPresence.getState());
// always bing if there are 0 bing words... apparently. // We need a way to let people get notifications for everything, if they so desire. The way to do this
// is to specify zero bingwords.
var bingWords = matrixService.config().bingWords; var bingWords = matrixService.config().bingWords;
if (bingWords === undefined || bingWords.length === 0) { if (bingWords === undefined || bingWords.length === 0) {
shouldBing = true; shouldBing = true;
} }
if (shouldBing) { if (shouldBing && isIdle) {
console.log("Displaying notification for "+JSON.stringify(event)); console.log("Displaying notification for "+JSON.stringify(event));
var member = $rootScope.events.rooms[event.room_id].members[event.user_id]; var member = $rootScope.events.rooms[event.room_id].members[event.user_id];
var displayname = undefined; var displayname = undefined;