diff options
author | Ollie H <renahlee@outlook.com> | 2023-05-17 07:46:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 09:46:10 -0500 |
commit | 656baa723913951e2a2961f00f0e5219660d0885 (patch) | |
tree | 60279f7792324959ddea143308f26dd98ec7d7c3 /src/view/com/lightbox/Lightbox.web.tsx | |
parent | 09bb2f52084724e9e5b000a7c59a78559c9b743e (diff) | |
download | voidsky-656baa723913951e2a2961f00f0e5219660d0885.tar.zst |
Close active elements on state change (#677)
Diffstat (limited to 'src/view/com/lightbox/Lightbox.web.tsx')
-rw-r--r-- | src/view/com/lightbox/Lightbox.web.tsx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/view/com/lightbox/Lightbox.web.tsx b/src/view/com/lightbox/Lightbox.web.tsx index eff9af2d2..d389279b1 100644 --- a/src/view/com/lightbox/Lightbox.web.tsx +++ b/src/view/com/lightbox/Lightbox.web.tsx @@ -21,6 +21,9 @@ interface Img { export const Lightbox = observer(function Lightbox() { const store = useStores() + + const onClose = useCallback(() => store.shell.closeLightbox(), [store.shell]) + if (!store.shell.isLightboxActive) { return null } @@ -29,8 +32,6 @@ export const Lightbox = observer(function Lightbox() { const initialIndex = activeLightbox instanceof models.ImagesLightbox ? activeLightbox.index : 0 - const onClose = () => store.shell.closeLightbox() - let imgs: Img[] | undefined if (activeLightbox instanceof models.ProfileImageLightbox) { const opts = activeLightbox |