Chat Info: Rerender status every minute (#5441)

This commit is contained in:
zubiden 2025-01-21 18:20:30 +01:00 committed by Alexander Zinchuk
parent e97ec38930
commit 1e77308175
2 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import { selectChatMessages, selectUser, selectUserStatus } from '../../global/s
import buildClassName from '../../util/buildClassName'; import buildClassName from '../../util/buildClassName';
import renderText from './helpers/renderText'; import renderText from './helpers/renderText';
import useIntervalForceUpdate from '../../hooks/schedulers/useIntervalForceUpdate';
import useLastCallback from '../../hooks/useLastCallback'; import useLastCallback from '../../hooks/useLastCallback';
import useOldLang from '../../hooks/useOldLang'; import useOldLang from '../../hooks/useOldLang';
@ -66,6 +67,8 @@ type StateProps =
isSynced?: boolean; isSynced?: boolean;
}; };
const UPDATE_INTERVAL = 1000 * 60; // 1 min
const PrivateChatInfo: FC<OwnProps & StateProps> = ({ const PrivateChatInfo: FC<OwnProps & StateProps> = ({
customPeer, customPeer,
typingStatus, typingStatus,
@ -116,6 +119,8 @@ const PrivateChatInfo: FC<OwnProps & StateProps> = ({
} }
}, [userId, withFullInfo, withMediaViewer, isSynced]); }, [userId, withFullInfo, withMediaViewer, isSynced]);
useIntervalForceUpdate(UPDATE_INTERVAL);
const handleAvatarViewerOpen = useLastCallback( const handleAvatarViewerOpen = useLastCallback(
(e: React.MouseEvent<HTMLDivElement, MouseEvent>, hasMedia: boolean) => { (e: React.MouseEvent<HTMLDivElement, MouseEvent>, hasMedia: boolean) => {
if (user && hasMedia) { if (user && hasMedia) {

View File

@ -0,0 +1,8 @@
import useForceUpdate from '../useForceUpdate';
import useInterval from './useInterval';
export default function useIntervalForceUpdate(interval?: number) {
const forceUpdate = useForceUpdate();
useInterval(forceUpdate, interval, true);
}