Skip to content

Commit

Permalink
Merge pull request #56523 from daledah/fix/55691
Browse files Browse the repository at this point in the history
fix: remove flashing effect when opening a report
  • Loading branch information
youssef-lr authored Mar 4, 2025
2 parents f21c548 + 09de108 commit 72916d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/hooks/useCurrentReportID.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import type {NavigationState} from '@react-navigation/native';
import React, {createContext, useCallback, useContext, useMemo, useState} from 'react';
import {useOnyx} from 'react-native-onyx';
import Navigation from '@libs/Navigation/Navigation';
import {getReportIDFromLink} from '@libs/ReportUtils';
import ONYXKEYS from '@src/ONYXKEYS';

type CurrentReportIDContextValue = {
updateCurrentReportID: (state: NavigationState) => void;
currentReportID: string | undefined;
currentReportIDFromPath: string | undefined;
};

type CurrentReportIDContextProviderProps = {
Expand All @@ -16,6 +20,8 @@ const CurrentReportIDContext = createContext<CurrentReportIDContextValue | null>

function CurrentReportIDContextProvider(props: CurrentReportIDContextProviderProps) {
const [currentReportID, setCurrentReportID] = useState<string | undefined>('');
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
const lastAccessReportFromPath = getReportIDFromLink(lastVisitedPath ?? null);

/**
* This function is used to update the currentReportID
Expand Down Expand Up @@ -46,8 +52,9 @@ function CurrentReportIDContextProvider(props: CurrentReportIDContextProviderPro
(): CurrentReportIDContextValue => ({
updateCurrentReportID,
currentReportID,
currentReportIDFromPath: lastAccessReportFromPath || undefined,
}),
[updateCurrentReportID, currentReportID],
[updateCurrentReportID, currentReportID, lastAccessReportFromPath],
);

return <CurrentReportIDContext.Provider value={contextValue}>{props.children}</CurrentReportIDContext.Provider>;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useReportIDs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function ReportIDsContextProvider({
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {accountID} = useCurrentUserPersonalDetails();
const currentReportIDValue = useCurrentReportID();
const derivedCurrentReportID = currentReportIDForTests ?? currentReportIDValue?.currentReportID;
const derivedCurrentReportID = currentReportIDForTests ?? currentReportIDValue?.currentReportIDFromPath ?? currentReportIDValue?.currentReportID;
const {activeWorkspaceID} = useActiveWorkspace();

const policyMemberAccountIDs = useMemo(() => getPolicyEmployeeListByIdWithoutCurrentUser(policies, activeWorkspaceID, accountID), [policies, activeWorkspaceID, accountID]);
Expand Down

0 comments on commit 72916d6

Please sign in to comment.