Skip to content

Commit

Permalink
updating var names to explain their use better
Browse files Browse the repository at this point in the history
  • Loading branch information
JediWattson committed Dec 15, 2022
1 parent 3965cff commit aab283f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ class AttachmentCarousel extends React.Component {
*/
makeStateWithReports() {
let page;
const actionsArr = ReportActionsUtils.getSortedReportActions(_.values(this.props.reportActions), true);
const actions = ReportActionsUtils.getSortedReportActions(_.values(this.props.reportActions), true);

/**
* Calling reducer will filter out attachments, determine the index of opened attachment,
* Calling reducer will filter out attachments,
* determine the index of opened attachment,
* and retrieve the src url and name of attachements
*/
const attachments = _.reduce(actionsArr, (attachmentsAccumulator, {originalMessage}) => {
const attachments = [];
_.forEach(actions, ({originalMessage}) => {
if (originalMessage && originalMessage.html) {
const matchesIt = originalMessage.html.matchAll(CONST.REGEX.ATTACHMENT_DATA);
const matches = [...matchesIt];
Expand All @@ -114,12 +116,12 @@ class AttachmentCarousel extends React.Component {
const [sourceURL, name] = _.map(matches, m => m[2]);
if ((this.state.sourceURL && sourceURL.includes(this.state.sourceURL))
|| (!this.state.sourceURL && sourceURL.includes(this.props.sourceURL))) {
page = attachmentsAccumulator.length;
page = attachments.length;
}
attachmentsAccumulator.push({sourceURL, file: {name}});
attachments.push({sourceURL, file: {name}});
}
}
return attachmentsAccumulator;
return attachments;
}, []);

const {sourceURL, file} = this.getAttachment(attachments[page]);
Expand Down

0 comments on commit aab283f

Please sign in to comment.