fix: retry a dashboard row's render when its url changes

This commit is contained in:
Tautvydas Derzinskas committed 2026-10-20 14:19:36 +02:00
1 parent 74ca5cbc0e
commit 401cc38461
2 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -78,7 +78,7 @@ function renderCover(plateId: string | null): Picture | null {
}
/** Each of `tags`' pictures of each kind, from its newest models that have one; joins images and plates for those
* alone, once for every kind. */
* alone, in one query every kind shares. */
export async function tagPictures(
prints: TaggedPrint[],
tags: string[],
@@ -16,8 +16,9 @@ const SIZE = 40;
*/
export default function DashboardModelThumb({ model }: { model: DashboardModel }) {
const [preference] = useCardPreview();
const [renderUnavailable, setRenderUnavailable] = useState(false);
const onUnavailable = useCallback(() => setRenderUnavailable(true), []);
// The render that couldn't be shown, so a new one for this row still gets its try.
const [failedRender, setFailedRender] = useState<string | null>(null);
const onUnavailable = useCallback(() => setFailedRender(model.render_url), [model.render_url]);
// Hidden until the choice is known, so the lists don't flash the wrong picture.
if (preference === null) return <ListItemAvatar sx={{ minWidth: 48 }} />;
@@ -28,7 +29,9 @@ export default function DashboardModelThumb({ model }: { model: DashboardModel }
</Avatar>
);
const renderUrl =
model.render_url && !renderUnavailable && (preference === "renders" || !photo) ? model.render_url : null;
model.render_url && model.render_url !== failedRender && (preference === "renders" || !photo)
? model.render_url
: null;
return (
<ListItemAvatar sx={{ minWidth: 48 }}>
{renderUrl ? (