Skip to content

Commit

Permalink
set loadStatus to loaded when image fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanCoulsonCA authored and Ryan Coulson committed Jan 23, 2025
1 parent 53f7df3 commit e7550d9
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/components/metadata-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -809,17 +809,24 @@ export default class MetadataEditorV extends Vue {
} else {
// Fill in the field with this value whether it exists or not.
this.metadata.logoName = logo;
// If it doesn't exist, maybe it's a remote file?
fetch(logo).then((data: Response) => {
if (data.status !== 404) {
data.blob().then((blob: Blob) => {
this.logoImage = new File([blob], this.metadata.logoName);
this.metadata.logoPreview = logo;
fetch(logo)
.then((data: Response) => {
if (data.status === 200) {
data.blob().then((blob: Blob) => {
this.logoImage = new File([blob], this.metadata.logoName);
this.metadata.logoPreview = logo;
this.loadStatus = 'loaded';
});
} else {
this.loadStatus = 'loaded';
});
}
});
this.metadata.logoPreview = 'error';
}
})
.catch((err) => {
this.loadStatus = 'loaded';
this.metadata.logoPreview = 'error';
});
}
} else {
// No logo to load.
Expand Down Expand Up @@ -1530,17 +1537,24 @@ export default class MetadataEditorV extends Vue {
} else {
// Fill in the field with this value whether it exists or not.
this.metadata.logoName = logo;
// If it doesn't exist, maybe it's a remote file?
fetch(logo).then((data: Response) => {
if (data.status !== 404) {
data.blob().then((blob: Blob) => {
this.logoImage = new File([blob], logoName);
this.metadata.logoPreview = logo;
fetch(logo)
.then((data: Response) => {
if (data.status === 200) {
data.blob().then((blob: Blob) => {
this.logoImage = new File([blob], logoName);
this.metadata.logoPreview = logo;
this.loadStatus = 'loaded';
});
} else {
this.loadStatus = 'loaded';
});
}
});
this.metadata.logoPreview = 'error';
}
})
.catch((err) => {
this.loadStatus = 'loaded';
this.metadata.logoPreview = 'error';
});
}
} else {
// If there's no logo, mark the product as loaded and remove any existing logos
Expand Down

0 comments on commit e7550d9

Please sign in to comment.