From d4355716703e4c3fbfd9d22f82c01ba715e03575 Mon Sep 17 00:00:00 2001 From: Roman Gafurov Date: Thu, 19 Sep 2024 23:58:42 +0400 Subject: [PATCH] fixup! fix(pages): encode users ids special chars (#83) (#84) --- src/pages/user/[id]/[[...deeplink]].tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/user/[id]/[[...deeplink]].tsx b/src/pages/user/[id]/[[...deeplink]].tsx index 3a2efea..f25727f 100644 --- a/src/pages/user/[id]/[[...deeplink]].tsx +++ b/src/pages/user/[id]/[[...deeplink]].tsx @@ -236,10 +236,13 @@ const User: NextPage = ({ (connection) => connection.platform.name === 'Discord', ); + const userId = encodeURIComponent(user.id); + useEffect(() => { setStats([]); + api.users - .stats(user.id, getTimeframeOptions(timeframe)) + .stats(userId, getTimeframeOptions(timeframe)) .then((stats) => { const hours = dayjs.duration(stats.durationMs).asHours(); @@ -277,7 +280,7 @@ const User: NextPage = ({ ]); }) .catch(() => {}); - }, [timeframe, user]); + }, [timeframe, userId]); useEffect(() => { const refs: Record> = { @@ -293,8 +296,6 @@ const User: NextPage = ({ }, []); // TODO: improvements - const userId = encodeURIComponent(user.id); - useEffect(() => { api.users .recentlyStreamed(userId) @@ -304,7 +305,7 @@ const User: NextPage = ({ useEffect(() => { api.users - .dateStats(user.id, { + .dateStats(userId, { ...getTimeframeOptions(timeframe), timeZone: user.timezone ?? @@ -319,7 +320,7 @@ const User: NextPage = ({ setDateStats(tempStats); }) .catch(() => {}); - }, [timeframe]); + }, [timeframe, userId]); const handleSegmentSelectSpotify = (value: BetterRange) => { event(`USER_switch_time_${value}`);