Chat Info: Rerender status every minute (#5441)
This commit is contained in:
parent
e97ec38930
commit
1e77308175
@ -16,6 +16,7 @@ import { selectChatMessages, selectUser, selectUserStatus } from '../../global/s
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import renderText from './helpers/renderText';
|
||||
|
||||
import useIntervalForceUpdate from '../../hooks/schedulers/useIntervalForceUpdate';
|
||||
import useLastCallback from '../../hooks/useLastCallback';
|
||||
import useOldLang from '../../hooks/useOldLang';
|
||||
|
||||
@ -66,6 +67,8 @@ type StateProps =
|
||||
isSynced?: boolean;
|
||||
};
|
||||
|
||||
const UPDATE_INTERVAL = 1000 * 60; // 1 min
|
||||
|
||||
const PrivateChatInfo: FC<OwnProps & StateProps> = ({
|
||||
customPeer,
|
||||
typingStatus,
|
||||
@ -116,6 +119,8 @@ const PrivateChatInfo: FC<OwnProps & StateProps> = ({
|
||||
}
|
||||
}, [userId, withFullInfo, withMediaViewer, isSynced]);
|
||||
|
||||
useIntervalForceUpdate(UPDATE_INTERVAL);
|
||||
|
||||
const handleAvatarViewerOpen = useLastCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement, MouseEvent>, hasMedia: boolean) => {
|
||||
if (user && hasMedia) {
|
||||
|
||||
8
src/hooks/schedulers/useIntervalForceUpdate.ts
Normal file
8
src/hooks/schedulers/useIntervalForceUpdate.ts
Normal 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);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user