Remove redundant freezes
This commit is contained in:
parent
9b841a5f31
commit
fa08832fca
@ -162,7 +162,6 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
const [hasFocusing, setHasFocusing] = useState<boolean>(Boolean(focusingId));
|
const [hasFocusing, setHasFocusing] = useState<boolean>(Boolean(focusingId));
|
||||||
|
|
||||||
const areMessagesLoaded = Boolean(messageIds);
|
const areMessagesLoaded = Boolean(messageIds);
|
||||||
const isFocusing = Boolean(focusingId);
|
|
||||||
|
|
||||||
useOnChange(() => {
|
useOnChange(() => {
|
||||||
// We only need it first time when message list appears
|
// We only need it first time when message list appears
|
||||||
@ -183,7 +182,7 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}, [firstUnreadId]);
|
}, [firstUnreadId]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
observe: observeIntersectionForMedia, freeze: freezeForMedia, unfreeze: unfreezeForMedia,
|
observe: observeIntersectionForMedia,
|
||||||
} = useIntersectionObserver({
|
} = useIntersectionObserver({
|
||||||
rootRef: containerRef,
|
rootRef: containerRef,
|
||||||
throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA,
|
throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA,
|
||||||
@ -236,16 +235,6 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
memoFocusingIdRef.current = focusingId;
|
memoFocusingIdRef.current = focusingId;
|
||||||
}, [focusingId]);
|
}, [focusingId]);
|
||||||
|
|
||||||
useOnChange(() => {
|
|
||||||
if (isFocusing) {
|
|
||||||
freezeForMedia();
|
|
||||||
freezeForReading();
|
|
||||||
} else {
|
|
||||||
unfreezeForReading();
|
|
||||||
unfreezeForMedia();
|
|
||||||
}
|
|
||||||
}, [isFocusing]);
|
|
||||||
|
|
||||||
const { observe: observeIntersectionForAnimatedStickers } = useIntersectionObserver({
|
const { observe: observeIntersectionForAnimatedStickers } = useIntersectionObserver({
|
||||||
rootRef: containerRef,
|
rootRef: containerRef,
|
||||||
throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA,
|
throttleMs: INTERSECTION_THROTTLE_FOR_MEDIA,
|
||||||
@ -545,7 +534,6 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
className="messages-container"
|
className="messages-container"
|
||||||
messageIds={messageIds || [lastMessage!.id]}
|
messageIds={messageIds || [lastMessage!.id]}
|
||||||
isFocusing={isFocusing}
|
|
||||||
loadMoreForwards={loadMoreForwards}
|
loadMoreForwards={loadMoreForwards}
|
||||||
loadMoreBackwards={loadMoreBackwards}
|
loadMoreBackwards={loadMoreBackwards}
|
||||||
isViewportNewest={isViewportNewest}
|
isViewportNewest={isViewportNewest}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ type OwnProps = {
|
|||||||
containerRef: MutableRefObject<HTMLDivElement | null>;
|
containerRef: MutableRefObject<HTMLDivElement | null>;
|
||||||
className: string;
|
className: string;
|
||||||
messageIds: number[];
|
messageIds: number[];
|
||||||
isFocusing: boolean;
|
|
||||||
loadMoreForwards?: NoneToVoidFunction;
|
loadMoreForwards?: NoneToVoidFunction;
|
||||||
loadMoreBackwards?: NoneToVoidFunction;
|
loadMoreBackwards?: NoneToVoidFunction;
|
||||||
isViewportNewest?: boolean;
|
isViewportNewest?: boolean;
|
||||||
@ -27,7 +26,6 @@ const MessageScroll: FC<OwnProps> = ({
|
|||||||
containerRef,
|
containerRef,
|
||||||
className,
|
className,
|
||||||
messageIds,
|
messageIds,
|
||||||
isFocusing,
|
|
||||||
loadMoreForwards,
|
loadMoreForwards,
|
||||||
loadMoreBackwards,
|
loadMoreBackwards,
|
||||||
isViewportNewest,
|
isViewportNewest,
|
||||||
@ -67,8 +65,6 @@ const MessageScroll: FC<OwnProps> = ({
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
observe: observeIntersection,
|
observe: observeIntersection,
|
||||||
freeze: freezeForLoadMore,
|
|
||||||
unfreeze: unfreezeForLoadMore,
|
|
||||||
} = useIntersectionObserver({
|
} = useIntersectionObserver({
|
||||||
rootRef: containerRef,
|
rootRef: containerRef,
|
||||||
margin: MESSAGE_LIST_SENSITIVE_AREA,
|
margin: MESSAGE_LIST_SENSITIVE_AREA,
|
||||||
@ -117,14 +113,6 @@ const MessageScroll: FC<OwnProps> = ({
|
|||||||
|
|
||||||
useOnIntersect(fabTriggerRef, observeIntersectionForNotch);
|
useOnIntersect(fabTriggerRef, observeIntersectionForNotch);
|
||||||
|
|
||||||
useOnChange(() => {
|
|
||||||
if (isFocusing) {
|
|
||||||
freezeForLoadMore();
|
|
||||||
} else {
|
|
||||||
unfreezeForLoadMore();
|
|
||||||
}
|
|
||||||
}, [isFocusing]);
|
|
||||||
|
|
||||||
// Workaround for FAB and notch flickering with tall incoming message
|
// Workaround for FAB and notch flickering with tall incoming message
|
||||||
useOnChange(() => {
|
useOnChange(() => {
|
||||||
freezeForFab();
|
freezeForFab();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user