feat: Add 'call' support to improve 2-way audio experience (#2486)
Draws significant inspiration (and direct styling) from https://github.com/dermotduffy/advanced-camera-card/pull/2447 . Thank you @Maudfer ! BREAKING CHANGE: The microphone condition previously bundled two unrelated signals — whether a two-way-audio session was connected and whether the microphone was muted. Connection state is now its own dedicated call condition, and microphone is reserved purely for mute state. Configs are upgraded automatically (the card rewrites affected conditions under overrides, elements, and automations). If you maintain config by hand, convert as follows: If you only used connected: # Before ```yaml condition: microphone connected: true ``` # After ```yaml condition: call call: true ``` If you used both connected and muted — they must be split into two conditions, since they no longer live together: # Before ```yaml condition: microphone connected: true muted: false ``` # After ```yaml condition: and conditions: - condition: call call: true - condition: microphone muted: false ```
This commit is contained in:
committed by
dermotduffy
parent
bb061a1a55
commit
abcba884e5
@@ -51,10 +51,29 @@ describe('should act correctly when view is set', () => {
|
||||
camera: 'camera',
|
||||
displayMode: 'grid',
|
||||
targetID: 'camera',
|
||||
substreamID: undefined,
|
||||
});
|
||||
expect(api.getCardElementManager().update).toBeCalled();
|
||||
});
|
||||
|
||||
it('should set the engaged substream in condition state', () => {
|
||||
const view = createView({
|
||||
view: 'live',
|
||||
camera: 'camera',
|
||||
context: { live: { overrides: new Map([['camera', 'substream']]) } },
|
||||
});
|
||||
|
||||
const factory = mock<ViewFactory>();
|
||||
factory.getViewDefault.mockReturnValue(view);
|
||||
|
||||
const api = createInitializedCardAPI();
|
||||
new ViewManager(api, { viewFactory: factory }).setViewDefault();
|
||||
|
||||
expect(api.getConditionStateManager()?.setState).toBeCalledWith(
|
||||
expect.objectContaining({ substreamID: 'substream' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('should set view with minor changes without scroll', () => {
|
||||
const view_1 = createView({
|
||||
view: 'live',
|
||||
@@ -305,6 +324,48 @@ it('should set view by parameters with existing query', async () => {
|
||||
expect(manager.getView()?.camera).toBe('camera');
|
||||
});
|
||||
|
||||
it('should set view by parameters with an explicitly provided existing query', async () => {
|
||||
const viewFactory = mock<ViewFactory>();
|
||||
viewFactory.getViewByParameters.mockReturnValue(createView());
|
||||
|
||||
const viewQueryExecutor = mock<ViewQueryExecutor>();
|
||||
viewQueryExecutor.getExistingQueryModifiers.mockResolvedValue([]);
|
||||
|
||||
const manager = new ViewManager(createInitializedCardAPI(), {
|
||||
viewFactory: viewFactory,
|
||||
viewQueryExecutor: viewQueryExecutor,
|
||||
});
|
||||
|
||||
const query = new UnifiedQuery();
|
||||
await manager.setViewByParametersWithExistingQuery({ params: { query } });
|
||||
|
||||
// An explicitly-passed query is used as-is rather than the base view's.
|
||||
expect(viewFactory.getViewByParameters).toBeCalledWith(
|
||||
expect.objectContaining({ params: expect.objectContaining({ query }) }),
|
||||
);
|
||||
});
|
||||
|
||||
it('should clear the query when an explicit null query is passed', async () => {
|
||||
const viewFactory = mock<ViewFactory>();
|
||||
viewFactory.getViewByParameters.mockReturnValue(createView());
|
||||
|
||||
const viewQueryExecutor = mock<ViewQueryExecutor>();
|
||||
viewQueryExecutor.getExistingQueryModifiers.mockResolvedValue([]);
|
||||
|
||||
const manager = new ViewManager(createInitializedCardAPI(), {
|
||||
viewFactory: viewFactory,
|
||||
viewQueryExecutor: viewQueryExecutor,
|
||||
});
|
||||
|
||||
await manager.setViewByParametersWithExistingQuery({ params: { query: null } });
|
||||
|
||||
// An explicit `null` is respected (clears the query), not overridden by the
|
||||
// base view's query.
|
||||
expect(viewFactory.getViewByParameters).toBeCalledWith(
|
||||
expect.objectContaining({ params: expect.objectContaining({ query: null }) }),
|
||||
);
|
||||
});
|
||||
|
||||
describe('should handle exceptions', () => {
|
||||
it('should retry with failSafe when no existing view in sync calls', () => {
|
||||
const viewFactory = mock<ViewFactory>();
|
||||
|
||||
Reference in New Issue
Block a user