Skip to content

Commit

Permalink
Show correct image in lightbox
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Feb 12, 2025
1 parent 6383988 commit 2bed0ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/v2.5/src/components/Images/ImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const ImageListImages: React.FC<IImageListImages> = ({
const handleImageOpen = useCallback(
(index) => {
setSlideshowRunning(true);
showLightbox(index, true);
showLightbox({ initialIndex: index, slideshowEnabled: true });
},
[showLightbox, setSlideshowRunning]
);
Expand Down
2 changes: 1 addition & 1 deletion ui/v2.5/src/components/Tagger/scenes/SceneTagger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const Tagger: React.FC<ITaggerProps> = ({ scenes, queue }) => {
});
function showLightboxImage(imagePath: string) {
setSpriteImage(imagePath);
showLightbox();
showLightbox({ images: lightboxImage });
}

const filteredScenes = useMemo(
Expand Down
9 changes: 5 additions & 4 deletions ui/v2.5/src/hooks/Lightbox/LightboxLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import { Button } from "react-bootstrap";
export const LightboxLink: React.FC<
PropsWithChildren<{ images?: ILightboxImage[] | undefined; index?: number }>
> = ({ images, index, children }) => {
const showLightbox = useLightbox({
images,
});
const showLightbox = useLightbox();

if (!images || images.length === 0) {
return <>{children}</>;
}

return (
<Button variant="link" onClick={() => showLightbox(index)}>
<Button
variant="link"
onClick={() => showLightbox({ images, initialIndex: index })}
>
{children}
</Button>
);
Expand Down
13 changes: 6 additions & 7 deletions ui/v2.5/src/hooks/Lightbox/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IState, useLightboxContext } from "./context";
import { IChapter } from "./types";

export const useLightbox = (
state: Partial<Omit<IState, "isVisible">>,
state: Partial<Omit<IState, "isVisible">> = {},
chapters: IChapter[] = []
) => {
const { setLightboxState } = useLightboxContext();
Expand Down Expand Up @@ -33,14 +33,13 @@ export const useLightbox = (
]);

const show = useCallback(
(index?: number, slideshowEnabled = false) => {
(props: Partial<IState>) => {
setLightboxState({
initialIndex: index,
...props,
isVisible: true,
slideshowEnabled,
page: state.page,
pages: state.pages,
pageSize: state.pageSize,
page: props.page ?? state.page,
pages: props.pages ?? state.pages,
pageSize: props.pageSize ?? state.pageSize,
chapters: chapters,
});
},
Expand Down

0 comments on commit 2bed0ae

Please sign in to comment.