Add FreshRSS widget (#1377)

* feat: add FreshRSS widget

* refactor: revert credentialed.js

* refactor: custom proxy handler for FreshRSS

* refactor: cache the token as long as possible

During installation, the salt is generated and remains constant unless
the user re-installs the FreshRSS instance.
This commit is contained in:
Heng-Yi Wu 2023-04-19 23:26:58 +08:00 committed by GitHub
parent 1aa559537a
commit e8713a95c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,33 @@
import { useTranslation } from "next-i18next";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: freshrssData, error: freshrssError } = useWidgetAPI(widget, "info");
if (freshrssError) {
return <Container error={freshrssError} />;
}
if (!freshrssData) {
return (
<Container service={service}>
<Block label="freshrss.unread" />
<Block label="freshrss.subscriptions" />
</Container>
);
}
return (
<Container service={service}>
<Block label="freshrss.unread" value={t("common.number", { value: freshrssData.unread })} />
<Block label="freshrss.subscriptions" value={t("common.number", { value: freshrssData.subscriptions })} />
</Container>
);
}