* Fix headers when preloading images * Import isGif Co-authored-by: Miguel Alatzar <this.migbot@gmail.com> Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
This commit is contained in:
parent
2418a3bdfd
commit
7f3798a547
2 changed files with 8 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ import {Client4} from 'mattermost-redux/client';
|
|||
|
||||
import ProgressiveImage from 'app/components/progressive_image';
|
||||
import {changeOpacity} from 'app/utils/theme';
|
||||
import {isGif} from 'app/utils/file';
|
||||
|
||||
import thumb from 'assets/images/thumb.png';
|
||||
|
||||
|
|
@ -55,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,
|
||||
|
|
@ -67,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);
|
||||
}
|
||||
|
||||
|
|
@ -98,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