Highlight speaker on group calls
This commit is contained in:
parent
3d4248e070
commit
23cbd2c8b3
6 changed files with 80 additions and 25 deletions
19
ts/hooks/useValueAtFixedRate.ts
Normal file
19
ts/hooks/useValueAtFixedRate.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useValueAtFixedRate<T>(value: T, rate: number): T {
|
||||
const [currentValue, setCurrentValue] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
setCurrentValue(value);
|
||||
}, rate);
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [value, rate]);
|
||||
|
||||
return currentValue;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue