-
Notifications
You must be signed in to change notification settings - Fork 43
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
💄 Hide blob list by default and add image viewer #252
Conversation
foysalit
commented
Dec 3, 2024
•
edited
Loading
edited
- To make more room in the Quick Action Panel, we are now hiding blob list by default, allowing mods to open it as a dropdown when they actually want to action blobs.
- Added an image viewer to the blob list so that mods can view each individual blob item.
- Fixed a bug ensuring we open the image that the user clicks in the lightbox view if there are multiple in a post, instead of the first one in the list.
![Screenshot 2024-12-03 at 20 31 49](https://private-user-images.githubusercontent.com/1919066/392129423-38aa6f4f-5add-44f8-b199-40ca49447b58.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MzQ5ODgsIm5iZiI6MTczOTkzNDY4OCwicGF0aCI6Ii8xOTE5MDY2LzM5MjEyOTQyMy0zOGFhNmY0Zi01YWRkLTQ0ZjgtYjE5OS00MGNhNDk0NDdiNTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTlUMDMxMTI4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Nzg1ZWJiNDAzNmUxYzY2MWM4NGIzNDA0MjM2ZDhjNzRjMjA4NzQyMzlmNjIyNjM2NGZkNjFiZTZlYWMxOWQ0MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.X_6IWpiz1bpkvs3574axSpHXvyK-ObH3mvUQrA43rCI)
![Screenshot 2024-12-03 at 20 35 33](https://private-user-images.githubusercontent.com/1919066/392129813-87a64ae6-ea6b-4fb8-a813-d3a10ec612d5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MzQ5ODgsIm5iZiI6MTczOTkzNDY4OCwicGF0aCI6Ii8xOTE5MDY2LzM5MjEyOTgxMy04N2E2NGFlNi1lYTZiLTRmYjgtYTgxMy1kM2ExMGVjNjEyZDUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTlUMDMxMTI4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDdiNWJhMjQxMGI2ODNhZWVjODYwMmIyYThjMTBiYzIxYzhlMjA3NDVjYjRmZjljZjZiOTk0OWRhMjBhZDA5ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.5gfItcWuiXUr6rMFqFUWhYiMb6h6obnElA1_s8YCcj8)
{!blobs.length ? ( | ||
<div className="text-sm text-gray-400">No blobs found</div> | ||
) : ( | ||
<BlobListLightbox | ||
blobs={blobs} | ||
authorDid={props.authorDid} | ||
slideIndex={lightboxImageIndex} | ||
onClose={() => setLightboxImageIndex(-1)} | ||
/> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: for the sake of readability I would invert the conditions blobs.length > 0 ? <BlobListLightbox /> : <div />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Some small comments
const { appview } = useServerConfig() | ||
const cdnUrl = appview?.endsWith('.bsky.app') | ||
? 'https://cdn.bsky.app' | ||
: appview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to make that part of the server config ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep but im trying to reduce server side touch points. i have a ticket on trello to send it from server.
console.log( | ||
blobs.map((blob) => ({ | ||
src: getBlobUrl({ | ||
cid: blob.cid, | ||
}), | ||
})), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log( | |
blobs.map((blob) => ({ | |
src: getBlobUrl({ | |
cid: blob.cid, | |
}), | |
})), | |
) |
const handleKeyDown = (event) => { | ||
if (event.key === 'Escape') { | ||
event.stopPropagation() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to useCallback
here. Otherwise the document.addEventListener('keydown', handleKeyDown)
and document.removeEventListener('keydown', handleKeyDown)
might not refer to the same function (resulting in the listener staying there forever)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ermm.. not sure if that's correct? what would the deps for the hook be? also, wouldn't it depend on how the exit and entered handler is defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to address this later and if we find this to be an issue, this will need to be updated in a few other places where lightbox is used.