Repository navigation
IoT Hub: fall back to initials when a creator avatar fails to load - #778
Closed
pinkevmladchy wants to merge 1 commit into
Closed
pinkevmladchy wants to merge 1 commit into
pinkevmladchy wants to merge 1 commit into
Conversation
Listing and creator pages are built ahead of time, so after a creator deletes their account the pages keep pointing at the removed /api/resources/<uuid> avatar until the next build and show a broken image. Render the initials block alongside the avatar (hidden) and reveal it if the image errors, matching the markup used when there is no avatar at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The IoT Hub now keeps a deleted creator's items published and only wipes their personal data:
avatarUrlbecomes null and the avatar resource (/api/resources/<uuid>) is deleted. Listing (/iot-hub/<category>/<slug>/) and creator (/iot-hub/creator/<id>/) pages are built ahead of time, so until the next site build they keep pointing at the deleted avatar and show a broken image.src/scripts/avatar-fallback.ts(new):initAvatarFallback()findsimg[data-avatar-img]. If the image fails to load, it removes the image and reveals the[data-avatar-initials]sibling. It also covers an image that already failed before the module script ran (complete && naturalWidth === 0).src/components/IotHub/CreatorHero.astro(140px photo) andsrc/components/IotHub/DetailMeta.astro(32px creator badge): the initials block is now rendered next to the avatar,hiddenwhile there is one, and each component loads the script. After a failed load the markup and styles match theavatarUrl = nullcase; the only addition is thedata-avatar-initialsattribute.No other "Deleted creator" handling: the public API has no flag for a deleted creator.
pnpm checkand eslint pass. Prettier warnings on the two.astrofiles predate this change. Not built locally.