Skip to content

Commit

Permalink
Merge pull request #519 from RyanCoulsonCA/fix-498
Browse files Browse the repository at this point in the history
set loadStatus to loaded when image fails to load
  • Loading branch information
szczz authored Jan 23, 2025
2 parents 53f7df3 + e7550d9 commit e62b236
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 e62b236

Please sign in to comment.