volume: Clarify some code

We have more idiomatic ways to check whether any element fullfills
some condition than breaking out of a loop.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
This commit is contained in:
Florian Müllner 2019-09-14 14:33:09 +02:00
parent 8d6820c4df
commit 1a32e3e74a

View File

@ -259,18 +259,17 @@ var InputStreamSlider = class extends StreamSlider {
_maybeShowInput() { _maybeShowInput() {
// only show input widgets if any application is recording audio // only show input widgets if any application is recording audio
let showInput = false; let showInput = false;
let recordingApps = this._control.get_source_outputs(); if (this._stream) {
if (this._stream && recordingApps) { // skip gnome-volume-control and pavucontrol which appear
for (let i = 0; i < recordingApps.length; i++) { // as recording because they show the input level
let outputStream = recordingApps[i]; let skippedApps = [
let id = outputStream.get_application_id(); 'org.gnome.VolumeControl',
// but skip gnome-volume-control and pavucontrol 'org.PulseAudio.pavucontrol'
// (that appear as recording because they show the input level) ];
if (!id || (id != 'org.gnome.VolumeControl' && id != 'org.PulseAudio.pavucontrol')) {
showInput = true; showInput = this._control.get_source_outputs().some(output => {
break; return !skippedApps.includes(output.get_application_id());
} });
}
} }
this._showInput = showInput; this._showInput = showInput;