Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frontend/src/components/Media/MediaView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@ export function MediaView({
const location = useLocation();
const { toggleFavourite } = useToggleFav();

// Loop to first image handler for slideshow
const handleLoopToStart = useCallback(() => {
dispatch(setCurrentViewIndex(0));
handlers.resetZoom();
}, [dispatch, handlers]);

// Slideshow functionality
const { isSlideshowActive, toggleSlideshow } = useSlideshow(
totalImages,
handleNextImage,
handleLoopToStart,
currentViewIndex,
);

// Folder Open functionality
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navigation/Sidebar/AppSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function AppSidebar() {
<SidebarFooter className="border-border/40 mt-auto border-t py-4">
<div className="text-muted-foreground space-y-1 px-4 text-xs">
<div className="font-medium">PictoPy v{version}</div>
<div>© 2025 PictoPy</div>
<div>© {new Date().getFullYear()} PictoPy</div>
</div>
</SidebarFooter>
</Sidebar>
Expand Down
20 changes: 17 additions & 3 deletions frontend/src/hooks/useSlideshow.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import { useState, useEffect, useCallback } from 'react';

export const useSlideshow = (totalImages: number, onNextImage: () => void) => {
export const useSlideshow = (
totalImages: number,
onNextImage: () => void,
onLoopToStart?: () => void,
currentIndex?: number,
) => {
const [isSlideshowActive, setIsSlideshowActive] = useState(false);

useEffect(() => {
let slideshowInterval: NodeJS.Timeout | null = null;

if (isSlideshowActive && totalImages > 1) {
slideshowInterval = setInterval(() => {
onNextImage();
// Loop back to first image when at the end
if (
currentIndex !== undefined &&
onLoopToStart &&
currentIndex >= totalImages - 1
) {
onLoopToStart();
} else {
onNextImage();
}
}, 3000);
}

Expand All @@ -17,7 +31,7 @@ export const useSlideshow = (totalImages: number, onNextImage: () => void) => {
clearInterval(slideshowInterval);
}
};
}, [isSlideshowActive, totalImages, onNextImage]);
}, [isSlideshowActive, totalImages, onNextImage, onLoopToStart, currentIndex]);

const toggleSlideshow = useCallback(() => {
setIsSlideshowActive((prev) => !prev);
Expand Down