From b455f29d072c5ab001f1d9c711674635a1a1d4a2 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Thu, 17 Apr 2025 22:46:55 -0400 Subject: [PATCH] Refactor image fetching in Banner and Logo editors to use our API client --- frontend/src/views/creators/BannerEditor.vue | 10 ++++++---- frontend/src/views/creators/CreatorLogoEditor.vue | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/creators/BannerEditor.vue b/frontend/src/views/creators/BannerEditor.vue index 33a67aa..331be9b 100644 --- a/frontend/src/views/creators/BannerEditor.vue +++ b/frontend/src/views/creators/BannerEditor.vue @@ -115,11 +115,13 @@ const onFileSelected = (event) => { const startEditing = () => { if (fileUrl.value && fileUrl.value !== fallbackUrl) { - // Create a temporary file from the current image URL - fetch(fileUrl.value) - .then(res => res.blob()) - .then(blob => { + // Use our API client to get the image + client.get(fileUrl.value, { responseType: 'blob' }) + .then(response => { + const blob = response.data selectedFile.value = new File([blob], 'current-image.jpg', { type: 'image/jpeg' }) + // Create a local URL for the cropper + fileUrl.value = URL.createObjectURL(blob) showCropper.value = true }) .catch(error => { diff --git a/frontend/src/views/creators/CreatorLogoEditor.vue b/frontend/src/views/creators/CreatorLogoEditor.vue index 074412a..bfe2be5 100644 --- a/frontend/src/views/creators/CreatorLogoEditor.vue +++ b/frontend/src/views/creators/CreatorLogoEditor.vue @@ -118,11 +118,13 @@ const onFileSelected = (event) => { const startEditing = () => { if (fileUrl.value && fileUrl.value !== fallbackUrl) { - // Create a temporary file from the current image URL - fetch(fileUrl.value) - .then(res => res.blob()) - .then(blob => { + // Use our API client to get the image + client.get(fileUrl.value, { responseType: 'blob' }) + .then(response => { + const blob = response.data selectedFile.value = new File([blob], 'current-image.jpg', { type: 'image/jpeg' }) + // Create a local URL for the cropper + fileUrl.value = URL.createObjectURL(blob) showCropper.value = true }) .catch(error => {