summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorPepijn <pepijnfens@gmail.com>2016-11-17 19:46:07 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-17 13:46:07 -0500
commit6d2882f6e70bc1c8794e0193a574dfe254b57d79 (patch)
treea9f2919afee7026c7009de7b1a5cb2010cadde34 /webapp/components
parenta7987149582a42e0f6d05813bc0f61fcdd6f805c (diff)
downloadchat-6d2882f6e70bc1c8794e0193a574dfe254b57d79.tar.gz
chat-6d2882f6e70bc1c8794e0193a574dfe254b57d79.tar.bz2
chat-6d2882f6e70bc1c8794e0193a574dfe254b57d79.zip
Don't show desktop notifications for messages entering the channel th… (#4216)
* Don't show desktop notifications for messages entering the channel the user is currently on Coding style fixes Allow notifications if browser tab is not focussed * Don't show desktop notifications for messages entering the channel the user is currently on Coding style fixes Allow notifications if browser tab is not focussed * Mute sound when a user doesn't get a desktop notification * Also play sound on desktop notifications * Fixed reviewer's remarks: * Removed double notification check * Removed direct links to browser store, created separate actions
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/logged_in.jsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/webapp/components/logged_in.jsx b/webapp/components/logged_in.jsx
index ec4ca2a6a..841061d48 100644
--- a/webapp/components/logged_in.jsx
+++ b/webapp/components/logged_in.jsx
@@ -109,6 +109,10 @@ export default class LoggedIn extends React.Component {
// Listen for user
UserStore.addChangeListener(this.onUserChanged);
+ // Listen for focussed tab/window state
+ window.addEventListener('focus', this.onFocusListener);
+ window.addEventListener('blur', this.onBlurListener);
+
// ???
$('body').on('mouseenter mouseleave', '.post', function mouseOver(ev) {
if (ev.type === 'mouseenter') {
@@ -166,6 +170,10 @@ export default class LoggedIn extends React.Component {
$('.modal').off('show.bs.modal');
$(window).off('keydown.preventBackspace');
+
+ // Listen for focussed tab/window state
+ window.removeEventListener('focus', this.onFocusListener);
+ window.removeEventListener('blur', this.onBlurListener);
}
render() {
@@ -177,6 +185,14 @@ export default class LoggedIn extends React.Component {
user: this.state.user
});
}
+
+ onFocusListener() {
+ GlobalActions.emitBrowserFocus(true);
+ }
+
+ onBlurListener() {
+ GlobalActions.emitBrowserFocus(false);
+ }
}
LoggedIn.propTypes = {