fix image url when using different host

This commit is contained in:
Guillaume Dorce 2022-11-18 10:17:27 +01:00
parent 37181d714a
commit f878fe314d
1 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { getMessages } from '@controllers/MessageController';
import { useQuery } from '@tanstack/react-query';
import { toastError } from '@controllers/Toasts';
import ScrollToBottom from './ScrollToBottom';
import { api } from '../main';
const MessageWrapper = () => {
const {
@ -10,6 +11,14 @@ const MessageWrapper = () => {
isLoading,
isError,
} = useQuery(['messages'], getMessages, {
onSuccess: (data) => {
data.map((message: any) => {
if (message.image) {
message.image = api.slice(0, -4) + message.image;
}
});
return data;
},
onError: (error) => {
toastError(error as string);
},