Skip to content

Commit

Permalink
fix(Service): Fix shortcut for (un)muting notifications & audio
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikGuzei committed Mar 7, 2019
1 parent a73e6bd commit 1df3342
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 40 deletions.
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"fs-extra": "7.0.1",
"hex-to-rgba": "1.0.2",
"jsonwebtoken": "^7.4.1",
"keymaster": "^1.6.2",
"lodash": "^4.17.4",
"mdi": "^1.9.33",
"mime-types": "2.1.21",
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/messages/src/lib/Menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,31 @@
"line": 189,
"column": 3
}
},
{
"id": "sidebar.muteApp",
"defaultMessage": "!!!Disable notifications & audio",
"file": "src/lib/Menu.js",
"start": {
"line": 190,
"column": 11
},
"end": {
"line": 193,
"column": 3
}
},
{
"id": "sidebar.unmuteApp",
"defaultMessage": "!!!Enable notifications & audio",
"file": "src/lib/Menu.js",
"start": {
"line": 194,
"column": 13
},
"end": {
"line": 197,
"column": 3
}
}
]
32 changes: 22 additions & 10 deletions src/lib/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ const menuItems = defineMessages({
id: 'menu.services.activatePreviousService',
defaultMessage: '!!!Activate previous service...',
},
muteApp: {
id: 'sidebar.muteApp',
defaultMessage: '!!!Disable notifications & audio',
},
unmuteApp: {
id: 'sidebar.unmuteApp',
defaultMessage: '!!!Enable notifications & audio',
},
});

function getActiveWebview() {
Expand Down Expand Up @@ -416,7 +424,7 @@ const _titleBarTemplateFactory = intl => [
},
{
label: intl.formatMessage(menuItems.zoomIn),
accelerator: `${ctrlKey}+Plus`,
accelerator: `${ctrlKey}+=`,
click() {
const activeService = getActiveWebview();
activeService.getZoomLevel((level) => {
Expand Down Expand Up @@ -702,34 +710,38 @@ export default class FranzMenu {

@computed get serviceTpl() {
const { intl } = window.franz;
const services = this.stores.services.allDisplayed;
const menu = [{
const { user, services, settings } = this.stores;
if (!user.isLoggedIn) return [];
const menu = [];

menu.push({
label: intl.formatMessage(menuItems.addNewService),
accelerator: `${cmdKey}+N`,
click: () => {
this.actions.ui.openSettings({ path: 'recipes' });
},
enabled: this.stores.user.isLoggedIn,
}, {
type: 'separator',
}, {
label: intl.formatMessage(menuItems.activateNextService),
accelerator: `${cmdKey}+alt+right`,
click: () => this.actions.service.setActiveNext(),
enabled: this.stores.user.isLoggedIn,
}, {
label: intl.formatMessage(menuItems.activatePreviousService),
accelerator: `${cmdKey}+alt+left`,
click: () => this.actions.service.setActivePrev(),
enabled: this.stores.user.isLoggedIn,
}, {
label: intl.formatMessage(
settings.all.app.isAppMuted ? menuItems.unmuteApp : menuItems.muteApp,
).replace('&', '&&'),
accelerator: `${cmdKey}+shift+m`,
click: () => this.actions.app.toggleMuteApp(),
}, {
type: 'separator',
}];

menu.push();
});

if (this.stores.user.isLoggedIn) {
services.forEach((service, i) => (menu.push({
services.allDisplayed.forEach((service, i) => (menu.push({
label: this._getServiceName(service),
accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null,
type: 'radio',
Expand Down
24 changes: 0 additions & 24 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
action, computed, observable, reaction,
} from 'mobx';
import moment from 'moment';
import key from 'keymaster';
import { getDoNotDisturb } from '@meetfranz/electron-notification-state';
import AutoLaunch from 'auto-launch';
import prettyBytes from 'pretty-bytes';
Expand Down Expand Up @@ -157,28 +156,6 @@ export default class AppStore extends Store {
this.stores.router.push(url);
});
// Global Mute
key(
'+shift+m ctrl+shift+m', () => {
this.actions.app.toggleMuteApp();
},
);
// We need to add an additional key listener for ctrl+ on windows. Otherwise only ctrl+shift+ would work
if (isWindows) {
key(
'ctrl+=', () => {
debug('Windows: zoom in via ctrl+');
const { webview } = this.stores.services.active;
webview.getZoomLevel((level) => {
// level 9 =~ +300% and setZoomLevel wouldnt zoom in further
if (level < 9) webview.setZoomLevel(level + 1);
});
},
);
}
this.locale = this._getDefaultLocale();
this._healthCheck();
Expand Down Expand Up @@ -290,7 +267,6 @@ export default class AppStore extends Store {
@action _muteApp({ isMuted, overrideSystemMute = true }) {
this.isSystemMuteOverridden = overrideSystemMute;
this.actions.settings.update({
type: 'app',
data: {
Expand Down

0 comments on commit 1df3342

Please sign in to comment.