From 3ab6b040b2fb343c229d4fe58b6c00051baa4753 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 19 Aug 2026 10:25:24 -0700 Subject: [PATCH] Fixhancement: handle linkwarden API change (#7018) --- src/widgets/linkwarden/component.jsx | 2 +- src/widgets/linkwarden/component.test.jsx | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/widgets/linkwarden/component.jsx b/src/widgets/linkwarden/component.jsx index d2bb40eb9..4bf449470 100644 --- a/src/widgets/linkwarden/component.jsx +++ b/src/widgets/linkwarden/component.jsx @@ -11,7 +11,7 @@ export default function Component({ service }) { // Some APIs return raw arrays, others wrap the payload (e.g. { response: [...] }). const collections = collectionsStatsData?.response ?? collectionsStatsData; - const tags = tagsStatsData?.response ?? tagsStatsData; + const tags = tagsStatsData?.response ?? tagsStatsData?.data?.tags ?? tagsStatsData; const totalLinks = Array.isArray(collections) ? collections.reduce((sum, collection) => sum + (collection._count?.links || 0), 0) diff --git a/src/widgets/linkwarden/component.test.jsx b/src/widgets/linkwarden/component.test.jsx index a87a7975b..b1791e766 100644 --- a/src/widgets/linkwarden/component.test.jsx +++ b/src/widgets/linkwarden/component.test.jsx @@ -67,4 +67,26 @@ describe("widgets/linkwarden/component", () => { expectBlockValue(container, "linkwarden.collections", 2); expectBlockValue(container, "linkwarden.tags", 4); }); + + it("computes the tags total from the nested Linkwarden API response", () => { + useWidgetAPI.mockImplementation((_widget, endpoint) => { + if (endpoint === "collections") { + return { data: { response: [{ _count: { links: 2 } }] }, error: undefined }; + } + + if (endpoint === "tags") { + return { data: { data: { tags: [{ id: 1 }, { id: 2 }, { id: 3 }] } }, error: undefined }; + } + + return { data: undefined, error: undefined }; + }); + + const { container } = renderWithProviders(, { + settings: { hideErrors: false }, + }); + + expectBlockValue(container, "linkwarden.links", 2); + expectBlockValue(container, "linkwarden.collections", 1); + expectBlockValue(container, "linkwarden.tags", 3); + }); });