Skip to content

Commit

Permalink
refactor: Rename size prop to type prop in Viewer ImageLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Mar 3, 2021
1 parent 395b543 commit e025386
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions react/Viewer/ImageLoader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ export class ImageLoader extends React.Component {

async loadLink() {
this.setState({ status: LOADING_LINK })
const { file, size, client } = this.props
const { file, linkType, client } = this.props

try {
const links = await this.getFileLinks(file, size)
const link = links[size]
const links = await this.getFileLinks(file, linkType)
const link = links[linkType]

if (!link) throw new Error(`${size} link is not available`)
if (!link) throw new Error(`${linkType} link is not available`)

const src = client.getStackClient().uri + link
await this.checkImageSource(src)
Expand Down Expand Up @@ -141,13 +141,13 @@ export class ImageLoader extends React.Component {
ImageLoader.propTypes = {
file: PropTypes.object.isRequired,
render: PropTypes.func.isRequired,
size: PropTypes.oneOf(['small', 'medium', 'large', 'preview']),
linkType: PropTypes.oneOf(['small', 'medium', 'large', 'preview']),
onError: PropTypes.func,
renderFallback: PropTypes.func
}

ImageLoader.defaultProps = {
size: 'small',
linkType: 'small',
onError: () => {}
}

Expand Down
2 changes: 1 addition & 1 deletion react/Viewer/ImageViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class ImageViewer extends Component {
{file && (
<ImageLoader
file={file}
size="large"
linkType="large"
onError={this.onImageError}
key={file.id}
render={src => (
Expand Down
2 changes: 1 addition & 1 deletion react/Viewer/PdfMobileViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const PdfMobileViewer = ({ file, t, gestures }) => {
{file && (
<ImageLoader
file={file}
size="preview"
linkType="preview"
onError={onImageError}
key={file.id}
render={src => (
Expand Down

0 comments on commit e025386

Please sign in to comment.