Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
a0c3da17
Commit
a0c3da17
authored
10 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
go back to the original behaviour of only notifying if we think the app is backgrounded or idle...
parent
4c7a1abd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webclient/components/matrix/event-handler-service.js
+14
-8
14 additions, 8 deletions
webclient/components/matrix/event-handler-service.js
with
14 additions
and
8 deletions
webclient/components/matrix/event-handler-service.js
+
14
−
8
View file @
a0c3da17
...
...
@@ -189,21 +189,27 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
if
(
window
.
Notification
&&
event
.
user_id
!=
matrixService
.
config
().
user_id
)
{
var
shouldBing
=
$rootScope
.
containsBingWord
(
event
.
content
.
body
);
// TODO: Binging every message when idle doesn't make much sense. Can we use this more sensibly?
// 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
// another window on top, we want to be notifying for those events. This DOES mean that there will be
// notifications when currently viewing the chat screen though, but that is preferable to the alternative imo.
// Ideally we would notify only when the window is hidden (i.e. document.hidden = true).
//
// However, Chrome on Linux and OSX currently returns document.hidden = false unless the window is
// explicitly showing a different tab. So we need another metric to determine hiddenness - we
// 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
());
// 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
;
if
(
bingWords
===
undefined
||
bingWords
.
length
===
0
)
{
shouldBing
=
true
;
}
if
(
shouldBing
)
{
if
(
shouldBing
&&
isIdle
)
{
console
.
log
(
"
Displaying notification for
"
+
JSON
.
stringify
(
event
));
var
member
=
$rootScope
.
events
.
rooms
[
event
.
room_id
].
members
[
event
.
user_id
];
var
displayname
=
undefined
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment