Skip to content

Commit

Permalink
moved auth token method into render to prevent undefined page
Browse files Browse the repository at this point in the history
  • Loading branch information
JediWattson committed Dec 6, 2022
1 parent 337dbf2 commit 2226040
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/AttachmentCarousel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AttachmentCarousel extends React.Component {
const sourceURL = _.get(attachmentItem, 'sourceURL', '');
const file = _.get(attachmentItem, 'file', {name: ''});
return {
sourceURL: addEncryptedAuthTokenToURL(sourceURL),
sourceURL,
file,
};
}
Expand Down Expand Up @@ -136,7 +136,7 @@ class AttachmentCarousel extends React.Component {

this.setState(({attachments, page}) => {
const nextIndex = page + deltaSlide;
if (nextIndex < 10) {
if (attachments.length - nextIndex < 10) {
Report.loadMoreActions(this.props.report.reportID, this.props.reportActions, this.props.report.isLoadingMoreReportActions);
}
const {sourceURL, file} = this.getAttachment(attachments[nextIndex]);
Expand All @@ -155,7 +155,7 @@ class AttachmentCarousel extends React.Component {
if (!this.state.sourceURL) {
return null;
}

const authSourceURL = addEncryptedAuthTokenToURL(this.state.sourceURL);
return (
<View
style={[styles.attachmentModalArrowsContainer]}
Expand Down Expand Up @@ -192,7 +192,7 @@ class AttachmentCarousel extends React.Component {
onPress={() => this.canUseTouchScreen && this.onShowArrow(!this.state.shouldShowArrow)}
onCycleThroughAttachments={this.cycleThroughAttachments}
>
<AttachmentView onPress={() => this.onShowArrow(!this.state.shouldShowArrow)} sourceURL={this.state.sourceURL} file={this.state.file} />
<AttachmentView onPress={() => this.onShowArrow(!this.state.shouldShowArrow)} sourceURL={authSourceURL} file={this.state.file} />
</CarouselActions>

</View>
Expand Down

0 comments on commit 2226040

Please sign in to comment.