Correctly load file attachment images (#4160)
* Correctly load file attachment images * Remove cache control from gallery
This commit is contained in:
parent
fda4948c8c
commit
0c7a2c6fa1
3 changed files with 15 additions and 11 deletions
|
|
@ -57,11 +57,16 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
|
||||
const {file} = props;
|
||||
if (file && file.id) {
|
||||
const preloadImages = [{uri: Client4.getFileThumbnailUrl(file.id)}];
|
||||
const headers = {
|
||||
Authorization: `Bearer ${Client4.getToken()}`,
|
||||
'X-CSRF-Token': Client4.csrf,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
};
|
||||
|
||||
if (isGif(file)) {
|
||||
preloadImages.push({uri: Client4.getFileUrl(file.id)});
|
||||
}
|
||||
const preloadImages = [
|
||||
{uri: Client4.getFileThumbnailUrl(file.id), headers},
|
||||
{uri: Client4.getFileUrl(file.id), headers},
|
||||
];
|
||||
|
||||
FastImage.preload(preloadImages);
|
||||
}
|
||||
|
|
@ -94,7 +99,7 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
imageProps.defaultSource = {uri: file.localPath};
|
||||
} else if (file.id) {
|
||||
imageProps.thumbnailUri = Client4.getFileThumbnailUrl(file.id);
|
||||
imageProps.imageUri = Client4.getFilePreviewUrl(file.id);
|
||||
imageProps.imageUri = Client4.getFileUrl(file.id);
|
||||
}
|
||||
return imageProps;
|
||||
};
|
||||
|
|
@ -149,6 +154,8 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
return this.renderSmallImage();
|
||||
}
|
||||
|
||||
const imageProps = this.imageProps(file);
|
||||
|
||||
return (
|
||||
<View
|
||||
ref={this.handleCaptureRef}
|
||||
|
|
@ -162,7 +169,7 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
filename={file.name}
|
||||
resizeMode={resizeMode}
|
||||
resizeMethod={resizeMethod}
|
||||
{...this.imageProps(file)}
|
||||
{...imageProps}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -120,10 +120,8 @@ export default class FileAttachmentList extends PureComponent {
|
|||
let uri;
|
||||
if (file.localPath) {
|
||||
uri = file.localPath;
|
||||
} else if (isGif(file)) {
|
||||
uri = Client4.getFileUrl(file.id);
|
||||
} else {
|
||||
uri = Client4.getFilePreviewUrl(file.id);
|
||||
uri = Client4.getFileUrl(file.id);
|
||||
}
|
||||
|
||||
results.push({
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ export default class ProgressiveImage extends PureComponent {
|
|||
load = () => {
|
||||
const {imageUri, thumbnailUri} = this.props;
|
||||
|
||||
if (thumbnailUri && imageUri) {
|
||||
FastImage.preload([{uri: imageUri}]);
|
||||
if (thumbnailUri) {
|
||||
this.setThumbnail(thumbnailUri);
|
||||
} else if (imageUri) {
|
||||
this.setImage(imageUri);
|
||||
|
|
|
|||
Loading…
Reference in a new issue