From 02eb134e402da7188b5e8aba6468ea9cce4ea0f8 Mon Sep 17 00:00:00 2001 From: "Timo K." Date: Wed, 18 Nov 2026 15:01:57 +0100 Subject: [PATCH] setEffect -> ClearEffect --- src/state/BackgroundEffects.test.ts | 8 ++++---- src/state/BackgroundEffects.ts | 10 ++++------ src/tracks/BackgroundEffectsContext.tsx | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/state/BackgroundEffects.test.ts b/src/state/BackgroundEffects.test.ts index 2ca5701c8..b31dc6337 100644 --- a/src/state/BackgroundEffects.test.ts +++ b/src/state/BackgroundEffects.test.ts @@ -75,7 +75,7 @@ describe("the pipeline's state", () => { const effects = createBackgroundEffects(testScope(), { supported: true, effect$: behavior(effect, { n: "none", b: "blur" }), - setEffect: vi.fn(), + clearEffect: vi.fn(), added$: new BehaviorSubject([]), canSegment: () => cold(answer, { y: true, n: false }), pipeline: fakePipeline().pipeline, @@ -110,7 +110,7 @@ describe("the pipeline's state", () => { describe("background effects", () => { let effect$: BehaviorSubject; let added$: BehaviorSubject; - let setEffect: (raw: string) => void; + let clearEffect: () => void; let fake: ReturnType; function build( @@ -119,7 +119,7 @@ describe("background effects", () => { return createBackgroundEffects(testScope(), { supported: true, effect$, - setEffect, + clearEffect, added$, canSegment: () => of(true), pipeline: fake.pipeline, @@ -135,7 +135,7 @@ describe("background effects", () => { beforeEach(() => { effect$ = new BehaviorSubject("none"); added$ = new BehaviorSubject(undefined); - setEffect = vi.fn((raw: string) => effect$.next(raw)); + clearEffect = vi.fn(() => effect$.next("none")); fake = fakePipeline(); }); diff --git a/src/state/BackgroundEffects.ts b/src/state/BackgroundEffects.ts index 0debe3a29..fee57bbdd 100644 --- a/src/state/BackgroundEffects.ts +++ b/src/state/BackgroundEffects.ts @@ -33,7 +33,6 @@ import { type Behavior } from "./Behavior"; import { type ObservableScope } from "./ObservableScope"; import { type BackgroundEffect, - type EffectId, imagePathFor, parseEffect, } from "../tracks/backgroundEffectCatalog"; @@ -57,9 +56,8 @@ export interface BackgroundEffectsOptions { supported: boolean; /** The effect chosen, as the setting stores it. */ effect$: Behavior; - /** Saves the chosen effect. Used to reset the choice to "none" when the - * chosen effect can't run here. */ - setEffect: (id: EffectId) => void; + /** Resets the choice to no effect, for when the chosen one can't run here. */ + clearEffect: () => void; /** The backgrounds the device keeps, undefined until it has said. */ added$: Behavior; /** Builds a segmenter on trial, and answers whether it could. */ @@ -81,7 +79,7 @@ export function createBackgroundEffects( { supported, effect$, - setEffect, + clearEffect, added$, canSegment, pipeline, @@ -108,7 +106,7 @@ export function createBackgroundEffects( added !== undefined && !added.some(({ id }) => id === effect.id)) ) - setEffect("none"); + clearEffect(); }); // Asked once an effect is first wanted. A browser update may fix what diff --git a/src/tracks/BackgroundEffectsContext.tsx b/src/tracks/BackgroundEffectsContext.tsx index a7675b5f8..5e605583a 100644 --- a/src/tracks/BackgroundEffectsContext.tsx +++ b/src/tracks/BackgroundEffectsContext.tsx @@ -57,7 +57,7 @@ export function createAppBackgroundEffects( return createBackgroundEffects(scope, { supported: supportsBackgroundProcessors(), effect$: backgroundEffectSetting.value$, - setEffect: backgroundEffectSetting.setValue, + clearEffect: () => backgroundEffectSetting.setValue("none"), added$: addedBackgrounds.added$, canSegment, pipeline: new BackgroundProcessorWrapper(transformer, "background-effect"),