Skip to content

Commit

Permalink
Merge pull request #42672 from tienifr/fix/41370
Browse files Browse the repository at this point in the history
fix Deeplinking to a whisper results in hmm it is not here page
  • Loading branch information
MonilBhavsar authored Jun 6, 2024
2 parents 056069e + b020a2e commit 59a37c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {getCurrentUserAccountID} from '@libs/actions/Report';
import Timing from '@libs/actions/Timing';
import Navigation from '@libs/Navigation/Navigation';
import clearReportNotifications from '@libs/Notification/clearReportNotifications';
Expand Down Expand Up @@ -618,15 +619,30 @@ function ReportScreen({
fetchReport();
}, [fetchReport]);

const isLinkedReportActionDeleted = useMemo(() => {
const {isLinkedReportActionDeleted, isInaccessibleWhisper} = useMemo(() => {
const currentUserAccountID = getCurrentUserAccountID();
if (!reportActionIDFromRoute || !sortedAllReportActions) {
return false;
return {isLinkedReportActionDeleted: false, isInaccessibleWhisper: false};
}
const action = sortedAllReportActions.find((item) => item.reportActionID === reportActionIDFromRoute);
return action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID);
return {
isLinkedReportActionDeleted: action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID),
isInaccessibleWhisper: action && ReportActionsUtils.isWhisperAction(action) && !(action?.whisperedToAccountIDs ?? []).includes(currentUserAccountID),
};
}, [reportActionIDFromRoute, sortedAllReportActions]);

if (isLinkedReportActionDeleted ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) {
// If user redirects to an inaccessible whisper via a deeplink, on a report they have access to,
// then we set reportActionID as empty string, so we display them the report and not the "Not found page".
useEffect(() => {
if (!isInaccessibleWhisper) {
return;
}
Navigation.isNavigationReady().then(() => {
Navigation.setParams({reportActionID: ''});
});
}, [isInaccessibleWhisper]);

if ((!isInaccessibleWhisper && isLinkedReportActionDeleted) ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) {
return (
<BlockingView
icon={Illustrations.ToddBehindCloud}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/ReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{

/** The admins's ID */
adminAccountID?: number;

/** These are the account IDs to whom a message was whispered. It is used to check if a specific user should be displayed a whisper message or not. */
whisperedToAccountIDs?: number[];
}>;

type ReportAction = ReportActionBase & OriginalMessage;
Expand Down

0 comments on commit 59a37c8

Please sign in to comment.