Fix immich widget error catching & awaiting data
This commit is contained in:
parent
dbcd6f5df7
commit
19cf9969b9
1 changed files with 18 additions and 7 deletions
|
@ -5,18 +5,29 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
|||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: immichData } = useWidgetAPI(widget);
|
||||
const { data: immichData, error: immichError } = useWidgetAPI(widget);
|
||||
|
||||
if (immichData?.statusCode) { // Unauthorized
|
||||
return <Container error={immichData?.statusCode} />;
|
||||
if (immichError || immichData?.statusCode === 401) {
|
||||
return <Container error={immichError ?? immichData} />;
|
||||
}
|
||||
|
||||
if (!immichData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="immich.users" />
|
||||
<Block label="immich.photos" />
|
||||
<Block label="immich.videos" />
|
||||
<Block label="immich.storage" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="immich.users" value={immichData?.usageByUser.length} />
|
||||
<Block label="immich.photos" value={immichData?.photos} />
|
||||
<Block label="immich.videos" value={immichData?.videos} />
|
||||
<Block label="immich.storage" value={immichData?.usage} />
|
||||
<Block label="immich.users" value={immichData.usageByUser.length} />
|
||||
<Block label="immich.photos" value={immichData.photos} />
|
||||
<Block label="immich.videos" value={immichData.videos} />
|
||||
<Block label="immich.storage" value={immichData.usage} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue