stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
23 lines (19 loc) • 753 B
text/typescript
import {
useMessageContext,
useMessageOverlayRuntimeContext,
useMessageOverlayTargetContext,
} from '../../../contexts';
import { useIsOverlayActive } from '../../../state-store';
import { DEFAULT_MESSAGE_OVERLAY_TARGET_ID } from '../messageOverlayConstants';
export const useShouldUseOverlayStyles = () => {
const { messageOverlayId } = useMessageContext();
const { messageOverlayTargetId } = useMessageOverlayRuntimeContext();
const isWithinMessageOverlayTarget = useMessageOverlayTargetContext();
const { active, closing } = useIsOverlayActive(messageOverlayId);
if (!active || closing) {
return false;
}
return messageOverlayTargetId === DEFAULT_MESSAGE_OVERLAY_TARGET_ID
? true
: isWithinMessageOverlayTarget;
};