[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
This commit is contained in:
Mark Hahnenberg 2017-02-06 12:33:31 -08:00
parent 6e09be9b4b
commit 91f55cebf5

View file

@ -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();
}