Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Cloudflare images image updating #4252

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Dec 4, 2024

image

Changes:

  • Functionality to upload a new version of an image
  • Standardizes API route names (they're all /images now)
  • Refactors API routes to extract common functions
  • Refactors image upload button into PostImageButton and PutImageButton + utils

@ikesau ikesau self-assigned this Dec 4, 2024
@ikesau ikesau mentioned this pull request Dec 4, 2024
@@ -152,6 +160,33 @@ function UserSelect({
)
}

// when updatedAt changes, the image will reload the src
// but it looks like sometimes cloudflare doesn't update in time :(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works sometimes, so maybe it's not worth it and we just let authors know that it can take up to a minute for the image to update after refreshing the page. Not sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't work reliably, I'd add the disclaimer to the page. I'm not sure if I understand the intended functionality. If we want to refresh the image every time the updatedAt changes, I think we could pass it as a key instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the key was the first thing I tried, but it wouldn't actually make a new request, and then when I tried forcing it to re-render, it would load the cached version, so this is the only way I found to make it work. (Though it also sometimes hits the CF cache 😫)

I think I'll just keep it as it currently is and see what the authors make of it. I'll probably have to explain in slack that sometimes the preview doesn't update and that they need to click on the image to see what the actual current image is. Seems.. fine 🤷

@owidbot
Copy link
Contributor

owidbot commented Dec 4, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-cloudflare-images-reupload

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-12-04 15:52:27 UTC
Execution time: 1.23 seconds

@ikesau ikesau requested a review from rakyi December 4, 2024 19:20
}
})
.catch(() => {
console.log("Something went wrong refreshing the image")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, we are effectively discarding the error here instead of letting it bubble up, which would be more helpful for debugging.

@@ -152,6 +160,33 @@ function UserSelect({
)
}

// when updatedAt changes, the image will reload the src
// but it looks like sometimes cloudflare doesn't update in time :(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't work reliably, I'd add the disclaimer to the page. I'm not sure if I understand the intended functionality. If we want to refresh the image every time the updatedAt changes, I think we could pass it as a key instead.

@ikesau ikesau merged commit 14e165a into cloudflare-images Dec 5, 2024
8 of 9 checks passed
@ikesau ikesau deleted the cloudflare-images-reupload branch December 5, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants