Skip to content

Commit

Permalink
Fixing duplicate Concierge chat
Browse files Browse the repository at this point in the history
Addressing the issue of duplicate Concierge chats appearing in the Left Hand Navigation (LHN) when deep linking to Concierge.
  • Loading branch information
ugogiordano authored Oct 30, 2024
1 parent 02eb28d commit 0705cee
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/pages/ConciergePage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {useFocusEffect} from '@react-navigation/native';
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useEffect, useRef} from 'react';
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {OnyxEntry, useOnyx,withOnyx} from 'react-native-onyx';

Check failure on line 5 in src/pages/ConciergePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Imports "OnyxEntry" are only used as type

Check failure on line 5 in src/pages/ConciergePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Insert `·`
import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView';
import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView';
import ScreenWrapper from '@components/ScreenWrapper';
Expand Down Expand Up @@ -33,21 +32,23 @@ function ConciergePage({session}: ConciergePageProps) {
const styles = useThemeStyles();
const isUnmounted = useRef(false);
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {initialValue: true});

useFocusEffect(() => {
if (session && 'authToken' in session) {
App.confirmReadyToOpenApp();
// Pop the concierge loading page before opening the concierge report.
Navigation.isNavigationReady().then(() => {
if (isUnmounted.current) {
return;
}
Report.navigateToConciergeChat(true, () => !isUnmounted.current);
});
} else {
Navigation.navigate();
}
});
useFocusEffect(
useCallback(() => {
if (session && 'authToken' in session) {
App.confirmReadyToOpenApp();
Navigation.isNavigationReady().then(() => {
if (isUnmounted.current || isLoadingReportData === undefined || !!isLoadingReportData) {
return;
}
Report.navigateToConciergeChat(true, () => !isUnmounted.current);
});
} else {
Navigation.navigate();
}
}, [session, isLoadingReportData]),
);

useEffect(() => {
isUnmounted.current = false;
Expand Down

0 comments on commit 0705cee

Please sign in to comment.