diff options
author | V <vendicated@riseup.net> | 2023-07-26 01:27:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 01:27:04 +0200 |
commit | 8620a1d86d302c23d51c1f6795f32cc8eb5e9207 (patch) | |
tree | d3144c2c84173c3d614499080505395f8b64352f /src/plugins/callTimer.tsx | |
parent | 198b35ffdce1ca7ba316409774bc816ac5b58e57 (diff) | |
download | Vencord-8620a1d86d302c23d51c1f6795f32cc8eb5e9207.tar.gz Vencord-8620a1d86d302c23d51c1f6795f32cc8eb5e9207.tar.bz2 Vencord-8620a1d86d302c23d51c1f6795f32cc8eb5e9207.zip |
New plugin: VoiceMessages (#1380)
Co-authored-by: V <vendicated@riseup.net>
Co-authored-by: Justice Almanzar <superdash993@gmail.com>
Diffstat (limited to 'src/plugins/callTimer.tsx')
-rw-r--r-- | src/plugins/callTimer.tsx | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/plugins/callTimer.tsx b/src/plugins/callTimer.tsx index 9490eba..2e0aa96 100644 --- a/src/plugins/callTimer.tsx +++ b/src/plugins/callTimer.tsx @@ -19,6 +19,7 @@ import { Settings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; +import { useTimer } from "@utils/react"; import definePlugin, { OptionType } from "@utils/types"; import { React } from "@webpack/common"; @@ -85,17 +86,10 @@ export default definePlugin({ }, Timer({ channelId }: { channelId: string; }) { - const [time, setTime] = React.useState(0); - const startTime = React.useMemo(() => Date.now(), [channelId]); + const time = useTimer({ + deps: [channelId] + }); - React.useEffect(() => { - const interval = setInterval(() => setTime(Date.now() - startTime), 1000); - return () => { - clearInterval(interval); - setTime(0); - }; - }, [channelId]); - - return <p style={{ margin: 0 }}>Connected for {formatDuration(time)}</p>; + return <p style={{ margin: 0 }}>Connected for <span style={{ fontFamily: "var(--font-code)" }}>{formatDuration(time)}</span></p>; } }); |