Skip to content

Commit

Permalink
Remove throws for unavailable display brightness drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Dec 23, 2023
1 parent 4d3836f commit 4e6fad3
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export class DisplayBrightnessControlService {
options: Partial<SetBrightnessOptions> = SET_BRIGHTNESS_OPTIONS_DEFAULTS
) {
const opt = { ...SET_BRIGHTNESS_OPTIONS_DEFAULTS, ...(options ?? {}) };
if (!(await firstValueFrom(this.driverIsAvailable))) {
throw 'DRIVER_UNAVAILABLE';
}
if (!(await firstValueFrom(this.driverIsAvailable))) return;
if (opt.cancelActiveTransition) this.cancelActiveTransition();
if (percentage == this.brightness) return;
this._brightness.next(percentage);
Expand All @@ -131,7 +129,6 @@ export class DisplayBrightnessControlService {
}

async fetchBrightness(): Promise<number | undefined> {
if (!(await firstValueFrom(this.driverIsAvailable))) throw 'DRIVER_UNAVAILABLE';
const brightness = (await this.driver.value?.getBrightnessPercentage()) ?? undefined;
if (brightness !== undefined) {
this._brightness.next(brightness);
Expand Down

0 comments on commit 4e6fad3

Please sign in to comment.