Fix headers when preloading images (#4165)
This commit is contained in:
parent
c35a34107a
commit
cd8c627dc3
2 changed files with 7 additions and 3 deletions
|
|
@ -56,7 +56,7 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
super(props);
|
||||
|
||||
const {file} = props;
|
||||
if (file && file.id) {
|
||||
if (file && file.id && !file.localPath) {
|
||||
const headers = {
|
||||
Authorization: `Bearer ${Client4.getToken()}`,
|
||||
'X-CSRF-Token': Client4.csrf,
|
||||
|
|
@ -68,6 +68,10 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
{uri: Client4.getFileUrl(file.id), headers},
|
||||
];
|
||||
|
||||
if (isGif(file)) {
|
||||
preloadImages.push({uri: Client4.getFilePreviewUrl(file.id), headers});
|
||||
}
|
||||
|
||||
FastImage.preload(preloadImages);
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +103,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.getFileUrl(file.id);
|
||||
imageProps.imageUri = isGif(file) ? Client4.getFilePreviewUrl(file.id) : Client4.getFileUrl(file.id);
|
||||
}
|
||||
return imageProps;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export const getAppCredentials = async () => {
|
|||
export const removeAppCredentials = async () => {
|
||||
const url = await getCurrentServerUrl();
|
||||
|
||||
Client4.setCSRF(null);
|
||||
Client4.setCSRF('');
|
||||
Client4.serverVersion = '';
|
||||
Client4.setUserId('');
|
||||
Client4.setToken('');
|
||||
|
|
|
|||
Loading…
Reference in a new issue