Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using report name value to check archived #45330

Merged
merged 9 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow

return (
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
{({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => (
<PressableWithoutFeedback
style={[style, isOffline && styles.cursorDefault]}
onPress={() => {
Expand All @@ -53,7 +53,9 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
onLongPress={(event) =>
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
}
shouldUseHapticsOnLongPress
accessibilityLabel={displayName}
role={CONST.ROLE.BUTTON}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function ImageRenderer({tnode}: ImageRendererProps) {
thumbnailImageComponent
) : (
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
{({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => (
<AttachmentContext.Consumer>
{({reportID, accountID, type}) => (
<PressableWithoutFocus
Expand All @@ -93,7 +93,9 @@ function ImageRenderer({tnode}: ImageRendererProps) {
Navigation.navigate(route);
}
}}
onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
onLongPress={(event) =>
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
}
shouldUseHapticsOnLongPress
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona

return (
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
{({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => (
<Text
suppressHighlighting
onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
onLongPress={(event) =>
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
}
onPress={(event) => {
event.preventDefault();
Navigation.navigate(navigationRoute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d
return (
<View style={isLast ? styles.mt2 : styles.mv2}>
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
{({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => (
<PressableWithoutFeedback
onPress={onPressIn ?? (() => {})}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
onLongPress={(event) =>
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
}
shouldUseHapticsOnLongPress
role={CONST.ROLE.PRESENTATION}
accessibilityLabel={translate('accessibilityHints.prestyledText')}
Expand Down
4 changes: 3 additions & 1 deletion src/components/ShowContextMenuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import * as ReportUtils from '@libs/ReportUtils';
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import CONST from '@src/CONST';
import type {Report, ReportAction} from '@src/types/onyx';
import type {Report, ReportAction, ReportNameValuePairs} from '@src/types/onyx';

type ShowContextMenuContextProps = {
anchor: ContextMenuAnchor;
report: OnyxEntry<Report>;
reportNameValuePairs: OnyxEntry<ReportNameValuePairs>;
action: OnyxEntry<ReportAction>;
transactionThreadReport?: OnyxEntry<Report>;
checkIfContextMenuActive: () => void;
Expand All @@ -20,6 +21,7 @@ type ShowContextMenuContextProps = {
const ShowContextMenuContext = createContext<ShowContextMenuContextProps>({
anchor: null,
report: undefined,
reportNameValuePairs: undefined,
action: undefined,
transactionThreadReport: undefined,
checkIfContextMenuActive: () => {},
Expand Down
6 changes: 4 additions & 2 deletions src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel}: Video
</View>
)}
<ShowContextMenuContext.Consumer>
{({anchor, report, action, checkIfContextMenuActive}) => (
{({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive}) => (
<PressableWithoutFeedback
style={[styles.videoThumbnailContainer]}
accessibilityLabel={accessibilityLabel}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
onPress={onPress}
onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
onLongPress={(event) =>
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs))
}
shouldUseHapticsOnLongPress
>
<View style={[styles.videoThumbnailPlayButton]}>
Expand Down
6 changes: 4 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,9 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
const lastOriginalReportAction = lastReportActions[reportID] ?? null;
let lastMessageTextFromReport = '';
const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID);

if (ReportUtils.isArchivedRoom(report)) {
if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) {
const archiveReason =
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
(ReportActionUtils.isClosedAction(lastOriginalReportAction) && ReportActionUtils.getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT;
Expand Down Expand Up @@ -786,10 +787,11 @@ function createOption(
let reportName;
result.participantsList = personalDetailList;
result.isOptimisticPersonalDetail = personalDetail?.isOptimisticPersonalDetail;
const reportNameValuePairs = ReportUtils.getReportNameValuePair(report?.reportID);
if (report) {
result.isChatRoom = ReportUtils.isChatRoom(report);
result.isDefaultRoom = ReportUtils.isDefaultRoom(report);
result.isArchivedRoom = ReportUtils.isArchivedRoom(report);
result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs);
result.isExpenseReport = ReportUtils.isExpenseReport(report);
result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report);
result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
Expand Down
Loading
Loading