1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

[PM-9552] add a toggle for the routing animation (#10005)

* add a toggle for the routing animation

* add missing period (thanks mat)

* rename routingAnimation to enableRoutingAnimation for consistency

* move animation-control.service.ts into abstractions

* simplify config option

* fixup! simplify config option

remove dead aria reference

---------

Co-authored-by: Shane Melton <smelton@bitwarden.com>
This commit is contained in:
slonkazoid
2024-08-24 00:13:43 +03:00
committed by GitHub
parent c2829cd71b
commit f2be150b70
7 changed files with 88 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
import { Observable, map } from "rxjs";
import { GlobalStateProvider, KeyDefinition, ANIMATION_DISK } from "../state";
export abstract class AnimationControlService {
/**
* The routing animation toggle.
*/
abstract enableRoutingAnimation$: Observable<boolean>;
/**
* A method for updating the state of the animation toggle.
* @param theme The new state.
*/
abstract setEnableRoutingAnimation(state: boolean): Promise<void>;
}
const ROUTING_ANIMATION = new KeyDefinition<boolean>(ANIMATION_DISK, "routing", {
deserializer: (s) => s,
});
export class DefaultAnimationControlService implements AnimationControlService {
private readonly enableRoutingAnimationState = this.globalStateProvider.get(ROUTING_ANIMATION);
enableRoutingAnimation$ = this.enableRoutingAnimationState.state$.pipe(
map((state) => state ?? this.defaultEnableRoutingAnimation),
);
constructor(
private globalStateProvider: GlobalStateProvider,
private defaultEnableRoutingAnimation: boolean = true,
) {}
async setEnableRoutingAnimation(state: boolean): Promise<void> {
await this.enableRoutingAnimationState.update(() => state, {
shouldUpdate: (currentState) => currentState !== state,
});
}
}