mirror of
https://github.com/TautvydasDerzinskas/Thingport.git
synced 2026-10-21 22:22:24 -05:00
fix: retry a dashboard row's render when its url changes
This commit is contained in:
1 parent
74ca5cbc0e
commit
401cc38461
2 files changed
+7
-4
No files matched your search
@@ -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 ? (
|
||||
|
||||
Reference in new issue
Block a user