Permalink
Browse files

feat(App): Respect System DoNotDisturb mode for service audio

Closes #162
  • Loading branch information...
adlk committed Nov 10, 2017
1 parent f5a9aa2 commit 7d41227cb78bed23fcac4c8b40dcadae57c098bc
Showing with 48 additions and 3 deletions.
  1. +1 −0 package.json
  2. +1 −1 src/containers/layout/AppLayoutContainer.js
  3. +12 −1 src/stores/AppStore.js
  4. +34 −1 yarn.lock
@@ -26,6 +26,7 @@
"author": "Stefan Malzner <stefan@adlk.io>",
"license": "Apache-2.0",
"dependencies": {
"@meetfranz/electron-notification-state": "^1.0.0",
"@paulcbetts/system-idle-time": "^1.0.4",
"address-rfc2822": "^2.0.1",
"auto-launch": "https://github.com/meetfranz/node-auto-launch.git",
@@ -81,7 +81,7 @@ export default class AppLayoutContainer extends Component {
<Sidebar
services={allServices}
setActive={setActive}
isAppMuted={settings.all.isMuted}
isAppMuted={app.isSystemMuted || settings.all.isMuted}
openSettings={openSettings}
closeSettings={closeSettings}
reorder={reorder}
@@ -2,7 +2,7 @@ import { remote, ipcRenderer, shell } from 'electron';
import { action, observable } from 'mobx';
import moment from 'moment';
import key from 'keymaster';
// import path from 'path';
import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
import idleTimer from '@paulcbetts/system-idle-time';
import AutoLaunch from 'auto-launch';
@@ -45,6 +45,8 @@ export default class AppStore extends Store {
miner = null;
@observable minerHashrate = 0.0;
@observable isSystemMuted = false;
constructor(...args) {
super(...args);
@@ -83,6 +85,11 @@ export default class AppStore extends Store {
// Needs to be delayed a bit
this._autoStart();
// Check if system is muted
// There are no events to subscribe so we need to poll everey 5s
this._systemDND();
setInterval(() => this._systemDND(), 5000);
// Check for updates once every 4 hours
setInterval(() => this._checkForUpdates(), CHECK_INTERVAL);
// Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues)
@@ -311,4 +318,8 @@ export default class AppStore extends Store {
async _checkAutoStart() {
return autoLauncher.isEnabled() || false;
}
_systemDND() {
this.isSystemMuted = getDoNotDisturb();
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

2 comments on commit 7d41227

@dancsonth

This comment has been minimized.

dancsonth replied Nov 17, 2017

Does this mean, that if system is on DND the entire app is muted (i.e. whatsapp video playback won't have audio) or does this just switch off notification sounds?

@adlk

This comment has been minimized.

Contributor

adlk replied Nov 17, 2017

@dancsonth the whole webview will me muted (no sounds at all)
While this is not a perfect solution, just disabling the services notification sound is not feasible at the current state.
While it is technically possible to fake an audio API and just filter certain audio files – a solution like this is so extremely error prone, especially with 3rd party recipe authors. The audio API alone is so much more complex than e.g. the notification API.

All in all, I wanted to have a better solution before adding this feature but there is a huge amount of requests to re-add this and we've made a quite good experience with this solution in the past.

Please sign in to comment.