mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
dont try to load image at all if shouldFetchMetadataFromApi (#4511)
Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
This commit is contained in:
parent
183f66c70c
commit
e060fef540
@ -130,6 +130,22 @@ export const imagesApi = api.injectEndpoints({
|
||||
extraOptions,
|
||||
fetchWithBaseQuery
|
||||
) => {
|
||||
if (args.shouldFetchMetadataFromApi) {
|
||||
let metadata;
|
||||
const metadataResponse = await fetchWithBaseQuery(
|
||||
`images/i/${args.image.image_name}/metadata`
|
||||
);
|
||||
if (metadataResponse.data) {
|
||||
const metadataResult = zCoreMetadata.safeParse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(metadataResponse.data as any)?.metadata
|
||||
);
|
||||
if (metadataResult.success) {
|
||||
metadata = metadataResult.data;
|
||||
}
|
||||
}
|
||||
return { data: { metadata } };
|
||||
} else {
|
||||
const authToken = $authToken.get();
|
||||
const projectId = $projectId.get();
|
||||
const customBaseQuery = fetchBaseQuery({
|
||||
@ -154,28 +170,12 @@ export const imagesApi = api.injectEndpoints({
|
||||
api,
|
||||
extraOptions
|
||||
);
|
||||
const blobData = await getMetadataAndWorkflowFromImageBlob(
|
||||
const data = await getMetadataAndWorkflowFromImageBlob(
|
||||
response.data as Blob
|
||||
);
|
||||
|
||||
let metadata = blobData.metadata;
|
||||
|
||||
if (args.shouldFetchMetadataFromApi) {
|
||||
const metadataResponse = await fetchWithBaseQuery(
|
||||
`images/i/${args.image.image_name}/metadata`
|
||||
);
|
||||
if (metadataResponse.data) {
|
||||
const metadataResult = zCoreMetadata.safeParse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(metadataResponse.data as any)?.metadata
|
||||
);
|
||||
if (metadataResult.success) {
|
||||
metadata = metadataResult.data;
|
||||
return { data };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { data: { ...blobData, metadata } };
|
||||
},
|
||||
providesTags: (result, error, { image }) => [
|
||||
{ type: 'ImageMetadataFromFile', id: image.image_name },
|
||||
|
Loading…
Reference in New Issue
Block a user