Skip to content

Commit

Permalink
fix(App): Fix notification sounds when app or services are muted
Browse files Browse the repository at this point in the history
Closes #1184 #900 #460 #1049
  • Loading branch information
adlk committed Dec 14, 2018
1 parent 735b2b7 commit 33b4c1e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/components/services/content/ServiceWebview.js
Expand Up @@ -18,7 +18,6 @@ export default @observer class ServiceWebview extends Component {
setWebviewReference: PropTypes.func.isRequired,
reload: PropTypes.func.isRequired,
edit: PropTypes.func.isRequired,
isAppMuted: PropTypes.bool.isRequired,
enable: PropTypes.func.isRequired,
isActive: PropTypes.bool,
};
Expand Down Expand Up @@ -69,7 +68,6 @@ export default @observer class ServiceWebview extends Component {
setWebviewReference,
reload,
edit,
isAppMuted,
enable,
} = this.props;

Expand Down Expand Up @@ -137,7 +135,6 @@ export default @observer class ServiceWebview extends Component {
})}
onUpdateTargetUrl={this.updateTargetUrl}
useragent={service.userAgent}
muted={isAppMuted || service.isMuted}
allowpopups
/>
)}
Expand Down
3 changes: 0 additions & 3 deletions src/components/services/content/Services.js
Expand Up @@ -26,7 +26,6 @@ export default @observer class Services extends Component {
openWindow: PropTypes.func.isRequired,
reload: PropTypes.func.isRequired,
openSettings: PropTypes.func.isRequired,
isAppMuted: PropTypes.bool.isRequired,
update: PropTypes.func.isRequired,
};

Expand All @@ -46,7 +45,6 @@ export default @observer class Services extends Component {
openWindow,
reload,
openSettings,
isAppMuted,
update,
} = this.props;
const { intl } = this.context;
Expand Down Expand Up @@ -81,7 +79,6 @@ export default @observer class Services extends Component {
openWindow={openWindow}
reload={() => reload({ serviceId: service.id })}
edit={() => openSettings({ path: `services/edit/${service.id}` })}
isAppMuted={isAppMuted}
enable={() => update({
serviceId: service.id,
serviceData: {
Expand Down
1 change: 0 additions & 1 deletion src/containers/layout/AppLayoutContainer.js
Expand Up @@ -108,7 +108,6 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e
openWindow={openWindow}
reload={reload}
openSettings={openSettings}
isAppMuted={settings.all.app.isAppMuted}
update={updateService}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/models/Service.js
Expand Up @@ -15,7 +15,7 @@ export default class Service {

events = {};

isAttached = false;
@observable isAttached = false;

@observable isActive = false; // Is current webview active

Expand Down
15 changes: 15 additions & 0 deletions src/stores/ServicesStore.js
Expand Up @@ -67,6 +67,7 @@ export default class ServicesStore extends Store {
this._mapActiveServiceToServiceModelReaction.bind(this),
this._saveActiveService.bind(this),
this._logoutReaction.bind(this),
this._handleMuteSettings.bind(this),
]);
// Just bind this
Expand Down Expand Up @@ -615,6 +616,20 @@ export default class ServicesStore extends Store {
}
}

_handleMuteSettings() {
const { enabled } = this;
const { isAppMuted } = this.stores.settings.app;

enabled.forEach((service) => {
const { isAttached } = service;
const isMuted = isAppMuted || service.isMuted;

if (isAttached) {
service.webview.setAudioMuted(isMuted);
}
});
}

_shareSettingsWithServiceProcess() {
const settings = this.stores.settings.app;
this.actions.service.sendIPCMessageToAllServices({
Expand Down

1 comment on commit 33b4c1e

@francwalter
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a release with it.

Please sign in to comment.