diff --git a/web/apps/cast/src/pages/slideshow.tsx b/web/apps/cast/src/pages/slideshow.tsx index c3e950783..6d1eee605 100644 --- a/web/apps/cast/src/pages/slideshow.tsx +++ b/web/apps/cast/src/pages/slideshow.tsx @@ -36,9 +36,10 @@ export default function Slideshow() { }; const advance = async () => { + console.log("in advance"); if (!urlGenerator) throw new Error("Unexpected state"); - const urls = await urlGenerator.next(); - if (!urls) { + const { value: urls, done } = await urlGenerator.next(); + if (done) { log.warn("Empty collection"); // Go back to pairing page router.push("/"); @@ -182,7 +183,10 @@ export default function Slideshow() { }; }, [loading]); - if (loading) return ; + console.log({ a: "render", loading, currentFileURL, nextFileURL }); + + if (loading || !currentFileURL || !nextFileURL) + return ; return ; } diff --git a/web/apps/cast/src/services/cast.ts b/web/apps/cast/src/services/cast.ts index 4312178c3..af069dfcf 100644 --- a/web/apps/cast/src/services/cast.ts +++ b/web/apps/cast/src/services/cast.ts @@ -78,15 +78,15 @@ export const readCastData = (): CastData => { * collection, and just moves onward to the next one. It will however throw if * there are errors in getting the collection itself. * - * If there are no renderable image in the collection, it resolves with - * `undefined`. + * If there are no renderable image in the collection, the sequence ends by + * yielding `done: true`. * * @param castData The collection to show and credentials to fetch the files * within it. */ export const renderableURLs = async function* (castData: CastData) { const { collectionKey, castToken } = castData; - let previousURL: string | undefined + let previousURL: string | undefined; while (true) { const collection = await getCollection(castToken, collectionKey); await syncPublicFiles(castToken, collection, () => {}); @@ -94,6 +94,7 @@ export const renderableURLs = async function* (castData: CastData) { const files = allFiles.filter((file) => isFileEligibleForCast(file)); for (const file of files) { + console.log("in generator", previousURL); if (!previousURL) { previousURL = await createRenderableURL(castToken, file); continue;