mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-25 22:35:49 +00:00
Follow the level$ rename through its uses
- The suggestion renamed the field in the type only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,18 +42,18 @@ type Story = StoryObj<typeof meta>;
|
|||||||
|
|
||||||
/** A quiet room: hiss below the noise floor lights nothing. */
|
/** A quiet room: hiss below the noise floor lights nothing. */
|
||||||
export const Silent: Story = {
|
export const Silent: Story = {
|
||||||
args: { state: { type: "level", level: constant(0) } },
|
args: { state: { type: "level", level$: constant(0) } },
|
||||||
play: async ({ canvasElement }) => {
|
play: async ({ canvasElement }) => {
|
||||||
await expect(litSegments(canvasElement)).toBe(0);
|
await expect(litSegments(canvasElement)).toBe(0);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const QuietSpeech: Story = {
|
export const QuietSpeech: Story = {
|
||||||
args: { state: { type: "level", level: constant(5) } },
|
args: { state: { type: "level", level$: constant(5) } },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NormalSpeech: Story = {
|
export const NormalSpeech: Story = {
|
||||||
args: { state: { type: "level", level: constant(12) } },
|
args: { state: { type: "level", level$: constant(12) } },
|
||||||
play: async ({ canvasElement }) => {
|
play: async ({ canvasElement }) => {
|
||||||
// A floor, not a count: the count follows from the design's bar and gap sizes.
|
// A floor, not a count: the count follows from the design's bar and gap sizes.
|
||||||
await expect(
|
await expect(
|
||||||
@@ -63,18 +63,18 @@ export const NormalSpeech: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const LoudSpeech: Story = {
|
export const LoudSpeech: Story = {
|
||||||
args: { state: { type: "level", level: constant(LEVEL_SCALE) } },
|
args: { state: { type: "level", level$: constant(LEVEL_SCALE) } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The three volumes differ in how many bars are lit, not only in colour. */
|
/** The three volumes differ in how many bars are lit, not only in colour. */
|
||||||
export const VolumesAreDistinguishable: Story = {
|
export const VolumesAreDistinguishable: Story = {
|
||||||
args: { state: { type: "level", level: constant(5) } },
|
args: { state: { type: "level", level$: constant(5) } },
|
||||||
play: async ({ canvasElement, mount }) => {
|
play: async ({ canvasElement, mount }) => {
|
||||||
const lit: number[] = [];
|
const lit: number[] = [];
|
||||||
for (const level of [5, 12, LEVEL_SCALE]) {
|
for (const level of [5, 12, LEVEL_SCALE]) {
|
||||||
await mount(
|
await mount(
|
||||||
<MicrophoneLevelMeter
|
<MicrophoneLevelMeter
|
||||||
state={{ type: "level", level: constant(level) }}
|
state={{ type: "level", level$: constant(level) }}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
lit.push(litSegments(canvasElement));
|
lit.push(litSegments(canvasElement));
|
||||||
@@ -121,7 +121,7 @@ export const NoDevice: Story = {
|
|||||||
|
|
||||||
/** The same meter at two widths: the bars keep their size and only their count changes. */
|
/** The same meter at two widths: the bars keep their size and only their count changes. */
|
||||||
export const ShapeStaysTheSameAtAnyWidth: Story = {
|
export const ShapeStaysTheSameAtAnyWidth: Story = {
|
||||||
args: { state: { type: "level", level: constant(12) } },
|
args: { state: { type: "level", level$: constant(12) } },
|
||||||
play: async ({ mount, args }) => {
|
play: async ({ mount, args }) => {
|
||||||
const narrow = await measureAt(mount, args, 180);
|
const narrow = await measureAt(mount, args, 180);
|
||||||
const wide = await measureAt(mount, args, 400);
|
const wide = await measureAt(mount, args, 400);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { constant } from "../state/Behavior";
|
|||||||
describe("MicrophoneLevelMeter", () => {
|
describe("MicrophoneLevelMeter", () => {
|
||||||
test("announces the level rather than relying on hue", () => {
|
test("announces the level rather than relying on hue", () => {
|
||||||
render(
|
render(
|
||||||
<MicrophoneLevelMeter state={{ type: "level", level: constant(6) }} />,
|
<MicrophoneLevelMeter state={{ type: "level", level$: constant(6) }} />,
|
||||||
);
|
);
|
||||||
|
|
||||||
const meter = screen.getByRole("meter", { name: "Microphone level" });
|
const meter = screen.getByRole("meter", { name: "Microphone level" });
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export const MicrophoneLevelMeter: FC<MicrophoneLevelMeterProps> = ({
|
|||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const element = segments.current;
|
const element = segments.current;
|
||||||
if (state.type !== "level" || element === null) return;
|
if (state.type !== "level" || element === null) return;
|
||||||
const subscription = state.level.subscribe((level) => {
|
const subscription = state.level$.subscribe((level) => {
|
||||||
element.setAttribute("aria-valuenow", String(level));
|
element.setAttribute("aria-valuenow", String(level));
|
||||||
element.setAttribute(
|
element.setAttribute(
|
||||||
"aria-valuetext",
|
"aria-valuetext",
|
||||||
@@ -121,9 +121,9 @@ export const MicrophoneLevelMeter: FC<MicrophoneLevelMeterProps> = ({
|
|||||||
aria-valuemin={0}
|
aria-valuemin={0}
|
||||||
aria-valuemax={LEVEL_SCALE}
|
aria-valuemax={LEVEL_SCALE}
|
||||||
// The first paint's value; the effect above keeps it current.
|
// The first paint's value; the effect above keeps it current.
|
||||||
aria-valuenow={state.level.value}
|
aria-valuenow={state.level$.value}
|
||||||
aria-valuetext={t("microphone_level.value", {
|
aria-valuetext={t("microphone_level.value", {
|
||||||
level: state.level.value,
|
level: state.level$.value,
|
||||||
max: LEVEL_SCALE,
|
max: LEVEL_SCALE,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ describe("useMicrophoneLevel", () => {
|
|||||||
|
|
||||||
// No level carried over from the previous device.
|
// No level carried over from the previous device.
|
||||||
const state = result.current;
|
const state = result.current;
|
||||||
expect(state.type === "level" ? state.level.value : state.type).toBe(0);
|
expect(state.type === "level" ? state.level$.value : state.type).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from "../state/MicrophoneLevel";
|
} from "../state/MicrophoneLevel";
|
||||||
import { constant } from "../state/Behavior";
|
import { constant } from "../state/Behavior";
|
||||||
|
|
||||||
const IDLE: MicrophoneState = { type: "level", level: constant(0) };
|
const IDLE: MicrophoneState = { type: "level", level$: constant(0) };
|
||||||
|
|
||||||
/** The live level of a microphone, captured only while `active`. */
|
/** The live level of a microphone, captured only while `active`. */
|
||||||
export function useMicrophoneLevel(
|
export function useMicrophoneLevel(
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ describe("observeMicrophoneState$", () => {
|
|||||||
let levels = 0;
|
let levels = 0;
|
||||||
const subscription = observeMicrophoneState$("mic1").subscribe((state) => {
|
const subscription = observeMicrophoneState$("mic1").subscribe((state) => {
|
||||||
states.push(state.type);
|
states.push(state.type);
|
||||||
if (state.type === "level") state.level.subscribe(() => levels++);
|
if (state.type === "level") state.level$.subscribe(() => levels++);
|
||||||
});
|
});
|
||||||
capture.grant();
|
capture.grant();
|
||||||
await vi.waitFor(() => expect(levels).toBe(1));
|
await vi.waitFor(() => expect(levels).toBe(1));
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export function observeMicrophoneState$(
|
|||||||
let previousFrame = performance.now();
|
let previousFrame = performance.now();
|
||||||
const current = new BehaviorSubject(0);
|
const current = new BehaviorSubject(0);
|
||||||
level = current;
|
level = current;
|
||||||
subscriber.next({ type: "level", level: current });
|
subscriber.next({ type: "level", level$: current });
|
||||||
|
|
||||||
const read = (): void => {
|
const read = (): void => {
|
||||||
analyser.getByteTimeDomainData(samples);
|
analyser.getByteTimeDomainData(samples);
|
||||||
|
|||||||
Reference in New Issue
Block a user