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

fix: 20214crash when opening the thread image #20338

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Tooltip from '../Tooltip';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import compose from '../../libs/compose';
import withWindowDimensions from '../withWindowDimensions';
import reportPropTypes from '../../pages/reportPropTypes';

const propTypes = {
/** source is used to determine the starting index in the array of attachments */
Expand All @@ -31,6 +32,9 @@ const propTypes = {
/** Object of report actions for this report */
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),

/** The report currently being looked at */
report: reportPropTypes.isRequired,

...withLocalizePropTypes,
};

Expand Down Expand Up @@ -148,7 +152,7 @@ class AttachmentCarousel extends React.Component {
* @returns {{page: Number, attachments: Array, shouldShowArrow: Boolean, containerWidth: Number, isZoomed: Boolean}}
*/
createInitialState() {
const actions = ReportActionsUtils.getSortedReportActions(_.values(this.props.reportActions));
const actions = [ReportActionsUtils.getParentReportAction(this.props.report), ...ReportActionsUtils.getSortedReportActions(_.values(this.props.reportActions))];
const attachments = [];

const htmlParser = new HtmlParser({
Expand Down Expand Up @@ -359,7 +363,7 @@ AttachmentCarousel.defaultProps = defaultProps;
export default compose(
withOnyx({
reportActions: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`,
canEvict: false,
},
}),
Expand Down
11 changes: 6 additions & 5 deletions src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ConfirmModal from './ConfirmModal';
import HeaderGap from './HeaderGap';
import SafeAreaConsumer from './SafeAreaConsumer';
import addEncryptedAuthTokenToURL from '../libs/addEncryptedAuthTokenToURL';
import reportPropTypes from '../pages/reportPropTypes';

/**
* Modal render prop component that exposes modal launching triggers that can be used
Expand Down Expand Up @@ -57,8 +58,8 @@ const propTypes = {
/** Title shown in the header of the modal */
headerTitle: PropTypes.string,

/** The ID of the report that has this attachment */
reportID: PropTypes.string,
/** The report that has this attachment */
report: reportPropTypes,

...withLocalizePropTypes,

Expand All @@ -72,7 +73,7 @@ const defaultProps = {
isAuthTokenRequired: false,
allowDownload: false,
headerTitle: null,
reportID: '',
report: {},
onModalShow: () => {},
onModalHide: () => {},
};
Expand Down Expand Up @@ -287,9 +288,9 @@ class AttachmentModal extends PureComponent {
onCloseButtonPress={() => this.setState({isModalOpen: false})}
/>
<View style={styles.imageModalImageCenterContainer}>
{this.props.reportID ? (
{!_.isEmpty(this.props.report) ? (
<AttachmentCarousel
reportID={this.props.reportID}
report={this.props.report}
onNavigate={this.onNavigate}
source={this.props.source}
onToggleKeyboard={this.updateConfirmButtonVisibility}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ImageRenderer = (props) => {
{({anchor, report, action, checkIfContextMenuActive}) => (
<AttachmentModal
allowDownload
reportID={report.reportID}
report={report}
source={source}
isAuthTokenRequired={isAttachment}
originalFileName={originalFileName}
Expand Down