From 8e64daf0ea5d50dd62b4e9bb0b60ce04c1e9a899 Mon Sep 17 00:00:00 2001 From: Florian Maul Date: Thu, 3 Aug 2023 12:21:04 +0200 Subject: [PATCH] fix: loading issue with ndk not being available --- src/components/SlideShow.tsx | 22 ++++++++++++++-------- src/components/SlideView/index.tsx | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/SlideShow.tsx b/src/components/SlideShow.tsx index e63c4ae..2344da2 100644 --- a/src/components/SlideShow.tsx +++ b/src/components/SlideShow.tsx @@ -12,7 +12,7 @@ import { isVideo, prepareContent, } from './nostrImageDownload'; -import { blockedPublicKeys, defaultRelays, adultContentTags, adultNPubs } from './env'; +import { blockedPublicKeys, adultContentTags, adultNPubs } from './env'; import Settings from './Settings'; import SlideView from './SlideView'; import GridView from './GridView'; @@ -24,6 +24,7 @@ import IconSettings from './Icons/IconSettings'; import IconPlay from './Icons/IconPlay'; import IconGrid from './Icons/IconGrid'; import useNav from '../utils/useNav'; + /* FEATURES: - improve mobile support @@ -60,7 +61,10 @@ const SlideShow = () => { const { currentSettings: settings } = useNav(); const fetch = () => { - if (!ndk) return; + if (!ndk) { + console.error('NDK not available.'); + return; + } const postSubscription = ndk.subscribe(buildFilter(settings.tags, settings.npubs, settings.showReposts)); @@ -102,12 +106,14 @@ const SlideShow = () => { }; useEffect(() => { - // reset all - setPosts([]); - images.current = []; - clearTimeout(fetchTimeoutHandle.current); - return fetch(); - }, [settings]); + if (ndk) { + // reset all + setPosts([]); + images.current = []; + clearTimeout(fetchTimeoutHandle.current); + fetch(); + } + }, [settings, ndk]); useEffect(() => { images.current = uniqBy( diff --git a/src/components/SlideView/index.tsx b/src/components/SlideView/index.tsx index 1b76d29..bb39058 100644 --- a/src/components/SlideView/index.tsx +++ b/src/components/SlideView/index.tsx @@ -105,7 +105,7 @@ const SlideView = ({ settings, images, setShowGrid }: SlideViewProps) => { // Make sure we have an image to start with but only trigger once if (!slideShowStarted && images.current.length > 2) { setSlideShowStarted(true); - queueNextImage(500); + queueNextImage(100); } }, [images.current.length]);