Fix user presence on RoomItem
This commit is contained in:
parent
c6ecfa17a3
commit
b2db5500b6
|
@ -40,14 +40,25 @@ const RoomItemContainer = ({
|
||||||
const alert = item.alert || item.tunread?.length;
|
const alert = item.alert || item.tunread?.length;
|
||||||
const connected = useAppSelector(state => state.meteor.connected);
|
const connected = useAppSelector(state => state.meteor.connected);
|
||||||
const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status);
|
const userStatus = useAppSelector(state => state.activeUsers[id || '']?.status);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const isDirect = !!(item.t === 'd' && id && !isGroupChat(item));
|
const isDirect = !!(item.t === 'd' && id && !isGroupChat(item));
|
||||||
|
|
||||||
|
// When app reconnects, we need to fetch the rendered user's presence
|
||||||
|
useEffect(() => {
|
||||||
if (connected && isDirect) {
|
if (connected && isDirect) {
|
||||||
getUserPresence(id);
|
getUserPresence(id);
|
||||||
}
|
}
|
||||||
}, [connected]);
|
}, [connected]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The component can be recycled by FlashList.
|
||||||
|
* When rid changes and there's no user's status, we need to fetch it
|
||||||
|
*/
|
||||||
|
useEffect(() => {
|
||||||
|
if (!userStatus && isDirect) {
|
||||||
|
getUserPresence(id);
|
||||||
|
}
|
||||||
|
}, [item.rid]);
|
||||||
|
|
||||||
const handleOnPress = () => onPress(item);
|
const handleOnPress = () => onPress(item);
|
||||||
|
|
||||||
const handleOnLongPress = () => onLongPress && onLongPress(item);
|
const handleOnLongPress = () => onLongPress && onLongPress(item);
|
||||||
|
|
Loading…
Reference in New Issue