mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Cache Pyload widget login sessionId, refactor
This commit is contained in:
@@ -7,15 +7,23 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { widget } = service;
|
||||
const { data: pyloadData, error: pyloadError } = useWidgetAPI(
|
||||
widget,
|
||||
"statusServer",
|
||||
);
|
||||
const { data: pyloadData, error: pyloadError } = useWidgetAPI(widget, "status");
|
||||
|
||||
if (pyloadError || !pyloadData) {
|
||||
if (pyloadError || pyloadData?.error) {
|
||||
return <Container error={t("widget.api_error")} />;
|
||||
}
|
||||
|
||||
if (!pyloadData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="pyload.speed" />
|
||||
<Block label="pyload.active" />
|
||||
<Block label="pyload.queue" />
|
||||
<Block label="pyload.total" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="pyload.speed" value={t("common.bitrate", { value: pyloadData.speed })} />
|
||||
|
||||
Reference in New Issue
Block a user