From 91f55cebf589e5e2c7ed00d828a60ae6b103421b Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Mon, 6 Feb 2017 12:33:31 -0800 Subject: [PATCH] [notification] Debounce new mail notification sound Summary: We don't want to overwhelm a user with a bunch of bings and bongs when they open their laptop after a long weekend. This diff takes a relatively simple approach by debouncing the notification sounds every 5 seconds. Test Plan: Run locally, make sure we still get notified but not too much. Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D3841 --- internal_packages/unread-notifications/lib/main.es6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal_packages/unread-notifications/lib/main.es6 b/internal_packages/unread-notifications/lib/main.es6 index 99181ac24..e99e28448 100644 --- a/internal_packages/unread-notifications/lib/main.es6 +++ b/internal_packages/unread-notifications/lib/main.es6 @@ -180,7 +180,8 @@ export class Notifier { } if (!this.hasScheduledNotify) { if (NylasEnv.config.get("core.notifications.sounds")) { - SoundRegistry.playSound('new-mail'); + this._playNewMailSound = this._playNewMailSound || _.debounce(() => SoundRegistry.playSound('new-mail'), 5000, true); + this._playNewMailSound(); } this._notifyMessages(); }