feat(DirectorySlideshow): update image loading logic to use stat for improved path handling
This commit is contained in:
parent
d8c8b0b4e1
commit
c6bc1fdd52
|
|
@ -1,6 +1,6 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { ChevronLeft, ChevronRight, Pause, Play } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Pause, Play } from 'lucide-react';
|
||||||
import { listDirectory, getWebDAVBaseUrl, type EntryInfo } from '../webdav';
|
import { listDirectory, stat, splitPath, getWebDAVBaseUrl, type EntryInfo } from '../webdav';
|
||||||
import { IMAGE_EXTS } from './MediaEntry';
|
import { IMAGE_EXTS } from './MediaEntry';
|
||||||
|
|
||||||
// Module-level cache: persists for the lifetime of the page session.
|
// Module-level cache: persists for the lifetime of the page session.
|
||||||
|
|
@ -60,7 +60,8 @@ export default function DirectorySlideshow({ path }: Props) {
|
||||||
// Fetch directory listing and preload all images eagerly.
|
// Fetch directory listing and preload all images eagerly.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!path) { setImages([]); return; }
|
if (!path) { setImages([]); return; }
|
||||||
listDirectory(path)
|
stat(path)
|
||||||
|
.then(info => listDirectory(info?.type === 'file' ? splitPath(path).parent : path))
|
||||||
.then(entries => {
|
.then(entries => {
|
||||||
const imgs = entries.filter(e => {
|
const imgs = entries.filter(e => {
|
||||||
if (e.type !== 'file') return false;
|
if (e.type !== 'file') return false;
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ export default function StatusPage({ config, setConfig, onOpenFileManager }: Sta
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeDevice = findActiveDevice();
|
const activeDevice = findActiveDevice();
|
||||||
const activeDir = activeDevice
|
const activeDir = activeDevice
|
||||||
? (activeDevice.base_url || splitPath(activeDevice.url || '/').parent)
|
? (activeDevice.base_url || activeDevice.url || null)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const mediaSetFiles: MediaSetEntry[] | null =
|
const mediaSetFiles: MediaSetEntry[] | null =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user