Update handling of local images in app.

This commit is contained in:
Patrick Fic
2022-09-26 15:11:47 -07:00
parent 96b6f14909
commit a1e0595690
2 changed files with 36 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ import {
} from "react-native";
import MediaCacheOverlay from "../media-cache-overlay/media-cache-overlay.component";
import * as Sentry from "sentry-expo";
import Toast from "react-native-toast-message";
import cleanAxios from "../../util/CleanAxios";
@@ -71,7 +72,14 @@ export default function JobDocumentsLocalComponent({ bodyshop, job }) {
}
async function getPhotos({ bodyshop, jobid, setImages }) {
const localmediaserverhttp = bodyshop.localmediaserverhttp.trim();
let localmediaserverhttp = bodyshop.localmediaserverhttp.trim();
if (localmediaserverhttp.endsWith("/")) {
localmediaserverhttp = localmediaserverhttp.slice(0, -1);
}
console.log(
"🚀 ~ file: job-documents-local.component.jsx ~ line 78 ~ localmediaserverhttp",
localmediaserverhttp
);
try {
const imagesFetch = await cleanAxios.post(
`${localmediaserverhttp}/jobs/list`,
@@ -86,18 +94,22 @@ async function getPhotos({ bodyshop, jobid, setImages }) {
.map((d, idx) => {
return {
...d,
// src: `${bodyshop.localmediaserverhttp}/${d.src}`.replace("//", "/"),
// src: `${localmediaserverhttp}/${d.src}`,
uri: `${bodyshop.localmediaserverhttp}/${d.src}`.replace("//", "/"),
thumbUrl: `${bodyshop.localmediaserverhttp}/${d.thumbnail}`.replace(
"//",
"/"
),
uri: `${localmediaserverhttp}${d.src}`,
thumbUrl: `${localmediaserverhttp}${d.thumbnail}`,
id: idx,
};
});
setImages(normalizedImages);
} catch (error) {
Sentry.Native.captureException(error);
Toast.show({
type: "error",
text1: `Error fetching photos.`,
text2: JSON.stringify(error),
});
}
}