mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Add tests for ReactionAudioRenderer
This commit is contained in:
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { ReactNode } from "react";
|
||||
import { ReactNode, useMemo } from "react";
|
||||
|
||||
import { useReactions } from "../useReactions";
|
||||
import { playReactionsSound, useSetting } from "../settings/settings";
|
||||
@@ -14,9 +14,20 @@ export function ReactionsAudioRenderer(): ReactNode {
|
||||
const { reactions } = useReactions();
|
||||
const [shouldPlay] = useSetting(playReactionsSound);
|
||||
|
||||
const expectedReactions = shouldPlay
|
||||
? [...new Set([...Object.values(reactions)])]
|
||||
: [];
|
||||
const expectedReactions = useMemo(() => {
|
||||
if (!shouldPlay) {
|
||||
return [];
|
||||
}
|
||||
const reactionsToPlayNames = new Set();
|
||||
return Object.values(reactions).filter((r) => {
|
||||
if (reactionsToPlayNames.has(r.name)) {
|
||||
return false;
|
||||
}
|
||||
reactionsToPlayNames.add(r.name);
|
||||
return true;
|
||||
});
|
||||
}, [shouldPlay, reactions]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{expectedReactions.map(
|
||||
|
||||
Reference in New Issue
Block a user