diff --git a/src/widgets/linkwarden/component.jsx b/src/widgets/linkwarden/component.jsx index 657d8b11..5803b9c7 100644 --- a/src/widgets/linkwarden/component.jsx +++ b/src/widgets/linkwarden/component.jsx @@ -7,21 +7,19 @@ import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { widget } = service; - // State to hold Stats const [stats, setStats] = useState({ totalLinks: null, collections: { total: null }, tags: { total: null }, }); - const { data: collectionsStatsData, error: collectionsStatsError } = useWidgetAPI(widget, "collections"); // Fetch Collection Stats - const { data: tagsStatsData, error: tagsStatsError } = useWidgetAPI(widget, "tags"); // Fetch Tag Stats + const { data: collectionsStatsData, error: collectionsStatsError } = useWidgetAPI(widget, "collections"); + const { data: tagsStatsData, error: tagsStatsError } = useWidgetAPI(widget, "tags"); - // Effect to update Stats when collectionsStatsData or tagsStatsData changes useEffect(() => { if (collectionsStatsData?.response && tagsStatsData?.response) { - /* eslint-disable no-underscore-dangle */ setStats({ + // eslint-disable-next-line no-underscore-dangle totalLinks: collectionsStatsData.response.reduce((sum, collection) => sum + (collection._count?.links || 0), 0), collections: { total: collectionsStatsData.response.length, @@ -30,7 +28,6 @@ export default function Component({ service }) { total: tagsStatsData.response.length, }, }); - /* eslint-enable no-underscore-dangle */ } }, [collectionsStatsData, tagsStatsData]); @@ -38,7 +35,6 @@ export default function Component({ service }) { return ; } - // Render when data is available return (