This commit is contained in:
meganrogge 2024-01-23 16:11:19 -08:00
parent 856d46ed86
commit 77fe3a1122
No known key found for this signature in database
GPG key ID: AA74638D4878183D
2 changed files with 12 additions and 2 deletions

View file

@ -22,6 +22,7 @@ export interface IAudioCueService {
isCueEnabled(cue: AudioCue): boolean;
isAlertEnabled(cue: AudioCue): boolean;
onEnabledChanged(cue: AudioCue): Event<void>;
onAlertEnabledChanged(cue: AudioCue): Event<void>;
playSound(cue: Sound, allowManyInParallel?: boolean): Promise<void>;
playAudioCueLoop(cue: AudioCue, milliseconds: number): IDisposable;
@ -235,6 +236,10 @@ export class AudioCueService extends Disposable implements IAudioCueService {
public onEnabledChanged(cue: AudioCue): Event<void> {
return Event.fromObservableLight(this.isCueEnabledCache.get({ cue }));
}
public onAlertEnabledChanged(cue: AudioCue): Event<void> {
return Event.fromObservableLight(this.isAlertEnabledCache.get({ cue }));
}
}

View file

@ -37,6 +37,11 @@ export class AudioCueLineFeatureContribution
() => this.audioCueService.isCueEnabled(cue)
));
private readonly isAlertEnabledCache = new CachedFunction<AudioCue, IObservable<boolean>>((cue) => observableFromEvent(
this.audioCueService.onAlertEnabledChanged(cue),
() => this.audioCueService.isAlertEnabled(cue)
));
constructor(
@IEditorService private readonly editorService: IEditorService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ -47,7 +52,7 @@ export class AudioCueLineFeatureContribution
const someAudioCueFeatureIsEnabled = derived(
(reader) => /** @description someAudioCueFeatureIsEnabled */ this.features.some((feature) =>
this.isEnabledCache.get(feature.audioCue).read(reader)
this.isEnabledCache.get(feature.audioCue).read(reader) || this.isAlertEnabledCache.get(feature.audioCue).read(reader)
)
);
@ -116,7 +121,7 @@ export class AudioCueLineFeatureContribution
const isFeaturePresent = derivedOpts(
{ debugName: `isPresentInLine:${feature.audioCue.name}` },
(reader) => {
if (!this.isEnabledCache.get(feature.audioCue).read(reader)) {
if (!this.isEnabledCache.get(feature.audioCue).read(reader) && !this.isAlertEnabledCache.get(feature.audioCue).read(reader)) {
return false;
}
const position = debouncedPosition.read(reader);