Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(gallery): without IntersectionObserver show every tile, computed in render (eslint set-state-in-effect)

purple2c88205083a2
diff --git a/src/components/create/experimental/CreatePanel.tsx b/src/components/create/experimental/CreatePanel.tsx
index 947dd317..2cab70ec 100644
--- a/src/components/create/experimental/CreatePanel.tsx
+++ b/src/components/create/experimental/CreatePanel.tsx
@@ -63,7 +63,10 @@ export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {
// thousands opens as fast as one of sixty. A new view starts at the top.
const viewKey = `${folderOpen ?? ''}\n${tagOpen ?? ''}\n${showHidden}`
const [page, setPage] = useState({ key: viewKey, n: GALLERY_PAGE })
- const limit = page.key === viewKey ? page.n : GALLERY_PAGE
+ // Without IntersectionObserver nothing would load the next page, so all of
+ // it is shown at once.
+ const canPage = typeof IntersectionObserver !== 'undefined'
+ const limit = !canPage ? count : page.key === viewKey ? page.n : GALLERY_PAGE
const shown = limit >= count ? gallery : gallery.slice(0, limit)
const scroller = useRef<HTMLDivElement | null>(null)
const sentinel = useRef<HTMLDivElement | null>(null)
@@ -71,10 +74,6 @@ export function CreatePanel({ open, onOpenChange, activeId, onSelect }: Props) {
useEffect(() => {
const end = sentinel.current
if (!more || !end) return
- if (typeof IntersectionObserver === 'undefined') {
- setPage({ key: viewKey, n: count })
- return
- }
const io = new IntersectionObserver((entries) => {
if (entries.some((e) => e.isIntersecting)) setPage((p) => ({ key: viewKey, n: (p.key === viewKey ? p.n : GALLERY_PAGE) + GALLERY_PAGE }))
}, { root: scroller.current, rootMargin: '400px 0px' })