Skip to content

Commit 4ee8d7b

Browse files
authored
Merge pull request Expensify#67012 from Krishna2323/krishna2323/issue/65972
fix: Chat -Skeleton loading when open start chat page.
2 parents 2951a12 + 96eccff commit 4ee8d7b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/pages/NewChatPage.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useFocusEffect} from '@react-navigation/native';
12
import isEmpty from 'lodash/isEmpty';
23
import reject from 'lodash/reject';
34
import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react';
@@ -19,7 +20,6 @@ import useLocalize from '@hooks/useLocalize';
1920
import useNetwork from '@hooks/useNetwork';
2021
import useOnyx from '@hooks/useOnyx';
2122
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
22-
import useScreenWrapperTransitionStatus from '@hooks/useScreenWrapperTransitionStatus';
2323
import useThemeStyles from '@hooks/useThemeStyles';
2424
import {navigateToAndOpenReport, searchInServer, setGroupDraft} from '@libs/actions/Report';
2525
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
@@ -60,7 +60,8 @@ function useOptions() {
6060
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true});
6161
const [newGroupDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {canBeMissing: true});
6262
const personalData = useCurrentUserPersonalDetails();
63-
const {didScreenTransitionEnd} = useScreenWrapperTransitionStatus();
63+
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
64+
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false);
6465
const {contacts} = useContactImport();
6566
const {options: listOptions, areOptionsInitialized} = useOptionsList({
6667
shouldInitialize: didScreenTransitionEnd,
@@ -100,6 +101,16 @@ function useOptions() {
100101
);
101102
}, [cleanSearchTerm, debouncedSearchTerm, options.personalDetails.length, options.recentReports.length, options.userToInvite, selectedOptions]);
102103

104+
useFocusEffect(
105+
useCallback(() => {
106+
focusTimeoutRef.current = setTimeout(() => {
107+
setDidScreenTransitionEnd(true);
108+
}, CONST.ANIMATED_TRANSITION);
109+
110+
return () => focusTimeoutRef.current && clearTimeout(focusTimeoutRef.current);
111+
}, []),
112+
);
113+
103114
useEffect(() => {
104115
if (!debouncedSearchTerm.length) {
105116
return;

tests/ui/NewChatPageTest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('NewChatPage', () => {
7676
});
7777
const spy = jest.spyOn(SectionList.prototype, 'scrollToLocation');
7878

79-
const addButton = screen.getAllByText(translateLocal('newChatPage.addToGroup')).at(0);
79+
const addButton = await waitFor(() => screen.getAllByText(translateLocal('newChatPage.addToGroup')).at(0));
8080
if (addButton) {
8181
fireEvent.press(addButton);
8282
expect(spy).toHaveBeenCalledWith(expect.objectContaining({itemIndex: 0}));

0 commit comments

Comments
 (0)