feat: optimizations

This commit is contained in:
Zamitto 2024-10-21 04:28:04 -03:00
parent fd5262cd6e
commit 27e8a0820f
6 changed files with 167 additions and 116 deletions

View file

@ -2,7 +2,7 @@ import { useNavigate } from "react-router-dom";
import { PeopleIcon } from "@primer/octicons-react";
import * as styles from "./sidebar-profile.css";
import { useAppSelector, useUserDetails } from "@renderer/hooks";
import { useEffect, useMemo, useRef } from "react";
import { useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { UserFriendModalTab } from "@renderer/pages/shared-modals/user-friend-modal";
import SteamLogo from "@renderer/assets/steam-logo.svg?react";
@ -13,8 +13,6 @@ const LONG_POLLING_INTERVAL = 60_000;
export function SidebarProfile() {
const navigate = useNavigate();
const pollingInterval = useRef<NodeJS.Timeout | null>(null);
const { t } = useTranslation("sidebar");
const {
@ -36,14 +34,12 @@ export function SidebarProfile() {
};
useEffect(() => {
pollingInterval.current = setInterval(() => {
const pollingInterval = setInterval(() => {
syncFriendRequests();
}, LONG_POLLING_INTERVAL);
return () => {
if (pollingInterval.current) {
clearInterval(pollingInterval.current);
}
clearInterval(pollingInterval);
};
}, [syncFriendRequests]);