Skip to content

Commit

Permalink
Merge pull request #45330 from DylanDylann/update-archive-function
Browse files Browse the repository at this point in the history
using report name value to check archived
  • Loading branch information
srikarparsi authored Jul 15, 2024
2 parents 5437054 + d89894c commit e129dca
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 83 deletions.
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 @@ -672,8 +672,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.getReportNameValuePairs(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 @@ -797,10 +798,11 @@ function createOption(
let reportName;
result.participantsList = personalDetailList;
result.isOptimisticPersonalDetail = personalDetail?.isOptimisticPersonalDetail;
const reportNameValuePairs = ReportUtils.getReportNameValuePairs(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

0 comments on commit e129dca

Please sign in to comment.