Skip to content

Commit dbda2b2

Browse files
authored
Add toggle to disable muted notifications (#5517)
1 parent 0d39b7d commit dbda2b2

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

app/components-react/root/StudioEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function StudioEditor() {
2828
AudioService,
2929
NotificationsService,
3030
JsonrpcService,
31+
DefaultHardwareService,
3132
} = Services;
3233
const performanceMode = useRealmObject(CustomizationService.state).performanceMode;
3334
const v = useVuex(() => ({
@@ -64,6 +65,7 @@ export default function StudioEditor() {
6465
const subscription = AudioService.audioNotificationUpdated.subscribe(notificationType => {
6566
if (timeoutHandles[notificationType]) return;
6667
if (!StreamingService.views.isStreaming && !StreamingService.views.isRecording) return;
68+
if (!DefaultHardwareService.state.enableMuteNotifications) return;
6769

6870
timeoutHandles[notificationType] = setTimeout(() => {
6971
timeoutHandles[notificationType] = undefined;

app/components-react/windows/advanced-audio/GlobalSettings.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const trackOptions = [
1919
];
2020

2121
export default function GlobalSettings() {
22-
const { SettingsService, UserService, StreamingService } = Services;
22+
const { SettingsService, UserService, StreamingService, DefaultHardwareService } = Services;
2323

2424
const {
2525
advancedAudioSettings,
@@ -33,6 +33,7 @@ export default function GlobalSettings() {
3333
isStreaming,
3434
isRecording,
3535
isMultiStreaming,
36+
enableMuteNotifications,
3637
} = useVuex(() => ({
3738
advancedAudioSettings: SettingsService.views.advancedAudioSettings,
3839
isAdvancedOutput: SettingsService.views.isAdvancedOutput,
@@ -45,6 +46,7 @@ export default function GlobalSettings() {
4546
isStreaming: StreamingService.views.isStreaming,
4647
isRecording: StreamingService.views.isRecording,
4748
isMultiStreaming: StreamingService.views.isMultiplatformMode,
49+
enableMuteNotifications: DefaultHardwareService.state.enableMuteNotifications,
4850
}));
4951

5052
const monitoringDevice = advancedAudioSettings?.parameters.find(
@@ -69,6 +71,10 @@ export default function GlobalSettings() {
6971
SettingsService.actions.setSettingValue('Output', type, value);
7072
}
7173

74+
function handleToggleMuteNotifications() {
75+
DefaultHardwareService.actions.toggleMuteNotifications();
76+
}
77+
7278
const shouldShowTwitchVODTrack = isAdvancedOutput && isTwitchAuthedAndActive && !isMultiStreaming;
7379

7480
return (
@@ -147,6 +153,11 @@ export default function GlobalSettings() {
147153
</div>
148154
</InputWrapper>
149155
)}
156+
<SwitchInput
157+
label={$t('Enable Muted Notifications')}
158+
value={enableMuteNotifications}
159+
onChange={handleToggleMuteNotifications}
160+
/>
150161
</ObsSettingsSection>
151162

152163
<ObsSettings page="Audio" />

app/i18n/en-US/audio.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
"Mic/Auxiliary Device 1": "Mic/Auxiliary Device 1",
4444
"Mic/Auxiliary Device 2": "Mic/Auxiliary Device 2",
4545
"Mic/Auxiliary Device 3": "Mic/Auxiliary Device 3",
46-
"Recording Audio Encoder": "Recording Audio Encoder"
46+
"Recording Audio Encoder": "Recording Audio Encoder",
47+
"Enable Muted Notifications": "Enable Muted Notifications"
4748
}

app/services/hardware/default-hardware.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ interface IDefaultHardwareServiceState {
1111
defaultVideoDevice: string;
1212
defaultAudioDevice: string;
1313
presetFilter: string;
14+
// TODO: This is probably more appropriate in the audio settings service once
15+
// that gets moved to the new API and we store FE settings but this is the closest
16+
// PersistentStatefulService I could find
17+
enableMuteNotifications: boolean;
1418
}
1519

1620
export class DefaultHardwareService extends PersistentStatefulService<IDefaultHardwareServiceState> {
1721
static defaultState: IDefaultHardwareServiceState = {
1822
defaultVideoDevice: null,
1923
defaultAudioDevice: 'default',
2024
presetFilter: '',
25+
enableMuteNotifications: true,
2126
};
2227

2328
@Inject() private hardwareService: HardwareService;
@@ -167,6 +172,10 @@ export class DefaultHardwareService extends PersistentStatefulService<IDefaultHa
167172
}
168173
}
169174

175+
toggleMuteNotifications() {
176+
this.SET_ENABLE_MUTE_NOTIFICATIONS(!this.state.enableMuteNotifications);
177+
}
178+
170179
@mutation()
171180
private SET_DEVICE(type: string, id: string) {
172181
if (type === 'video') {
@@ -180,4 +189,9 @@ export class DefaultHardwareService extends PersistentStatefulService<IDefaultHa
180189
private SET_PRESET_FILTER(filter: string) {
181190
this.state.presetFilter = filter;
182191
}
192+
193+
@mutation()
194+
private SET_ENABLE_MUTE_NOTIFICATIONS(val: boolean) {
195+
this.state.enableMuteNotifications = val;
196+
}
183197
}

0 commit comments

Comments
 (0)