Fix: handle immich v1.85.0 API stats breaking change (#2284)

pull/2292/head
shamoon 1 year ago committed by GitHub
parent 885a4051f3
commit 7719ea17be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,10 +8,13 @@ export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: immichData, error: immichError } = useWidgetAPI(widget);
const { data: versionData, error: versionError } = useWidgetAPI(widget, "version");
// see https://github.com/gethomepage/homepage/issues/2282
const endpoint = versionData?.major >= 1 && versionData?.minor > 84 ? "statistics" : "stats";
const { data: immichData, error: immichError } = useWidgetAPI(widget, endpoint);
if (immichError || immichData?.statusCode === 401) {
return <Container service={service} error={immichError ?? immichData} />;
if (immichError || versionError || immichData?.statusCode === 401) {
return <Container service={service} error={immichData ?? immichError ?? versionError} />;
}
if (!immichData) {

@ -1,8 +1,20 @@
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
const widget = {
api: "{url}/api/server-info/stats",
api: "{url}/api/server-info/{endpoint}",
proxyHandler: credentialedProxyHandler,
mappings: {
version: {
endpoint: "version",
},
statistics: {
endpoint: "statistics",
},
stats: {
endpoint: "stats",
},
},
};
export default widget;

Loading…
Cancel
Save