Mute default source/sink if none selected

This commit is contained in:
futpib 2018-11-20 14:33:22 +03:00
parent fb6ce97b55
commit 143dcce068
2 changed files with 25 additions and 0 deletions

View File

@ -55,6 +55,9 @@ const {
getModuleSourceOutputs,
getSinkSinkInputs,
getDefaultSinkPai,
getDefaultSourcePai,
} = require('../../selectors');
const {
@ -980,6 +983,8 @@ class Graph extends React.Component {
hotKeyMute() {
if (!this.state.selected) {
const defaultSink = getDefaultSinkPai({ pulse: this.props });
this.toggleMute(defaultSink);
return;
}
@ -994,6 +999,8 @@ class Graph extends React.Component {
hotKeyShiftMute() {
if (!this.state.selected) {
const defaultSource = getDefaultSourcePai({ pulse: this.props });
this.toggleMute(defaultSource);
return;
}

View File

@ -4,8 +4,11 @@ const {
prop,
path,
filter,
find,
indexBy,
pickBy,
propEq,
values,
} = require('ramda');
const { createSelector } = require('reselect');
@ -51,6 +54,18 @@ const getDerivedMonitorSources = createSelector(
}), filter(source => source.monitorSourceIndex >= 0, sources)),
);
const getDefaultSourcePai = createSelector(
state => state.pulse.infos.sources,
state => state.pulse.serverInfo.defaultSourceName,
(sources, defaultSourceName) => find(propEq('name', defaultSourceName), values(sources)),
);
const getDefaultSinkPai = createSelector(
state => state.pulse.infos.sinks,
state => state.pulse.serverInfo.defaultSinkName,
(sinks, defaultSinkName) => find(propEq('name', defaultSinkName), values(sinks)),
);
module.exports = {
getPaiByTypeAndIndex,
getDerivedMonitorSources,
@ -62,4 +77,7 @@ module.exports = {
getModuleSourceOutputs,
getSinkSinkInputs,
getDefaultSinkPai,
getDefaultSourcePai,
};