Skip to content

Commit

Permalink
fix Deeplinking to a whisper results in hmm it is not here page
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed May 27, 2024
1 parent 9a87ce9 commit 7503d76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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 @@ -625,15 +626,25 @@ 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: ReportActionsUtils.isWhisperAction(action) && !(action?.whisperedToAccountIDs ?? []).includes(currentUserAccountID),
};
}, [reportActionIDFromRoute, sortedAllReportActions]);

if (isLinkedReportActionDeleted ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) {
useEffect(() => {

Check failure on line 641 in src/pages/home/ReportScreen.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

Prefer an early return to a conditionally-wrapped function body
if (isInaccessibleWhisper) {
Navigation.setParams({reportActionID: ''});
}
}, [isInaccessibleWhisper]);

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

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

whisperedToAccountIDs?: number[];
}>;

type ReportAction = ReportActionBase & OriginalMessage;
Expand Down

0 comments on commit 7503d76

Please sign in to comment.