From 5ae49cab49d88985485531e8b4a661e624034cef Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 18 Apr 2026 13:18:51 +0100 Subject: [PATCH] refactor(base): prune deleted property cells locally instead of invalidating rows --- .../base/queries/base-property-query.ts | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/client/src/features/base/queries/base-property-query.ts b/apps/client/src/features/base/queries/base-property-query.ts index c0a9c178..f1ad8acb 100644 --- a/apps/client/src/features/base/queries/base-property-query.ts +++ b/apps/client/src/features/base/queries/base-property-query.ts @@ -1,4 +1,4 @@ -import { useMutation } from "@tanstack/react-query"; +import { InfiniteData, useMutation } from "@tanstack/react-query"; import { createProperty, updateProperty, @@ -8,6 +8,7 @@ import { import { IBase, IBaseProperty, + IBaseRow, CreatePropertyInput, UpdatePropertyInput, DeletePropertyInput, @@ -17,6 +18,7 @@ import { import { notifications } from "@mantine/notifications"; import { queryClient } from "@/main"; import { useTranslation } from "react-i18next"; +import { IPagination } from "@/lib/types"; export function useCreatePropertyMutation() { const { t } = useTranslation(); @@ -100,9 +102,23 @@ export function useDeletePropertyMutation() { }, ); - queryClient.invalidateQueries({ - queryKey: ["base-rows", variables.baseId], - }); + queryClient.setQueriesData>>( + { queryKey: ["base-rows", variables.baseId] }, + (old) => { + if (!old) return old; + return { + ...old, + pages: old.pages.map((page) => ({ + ...page, + items: page.items.map((row) => { + if (!(variables.propertyId in row.cells)) return row; + const { [variables.propertyId]: _, ...rest } = row.cells; + return { ...row, cells: rest }; + }), + })), + }; + }, + ); }, onError: () => { notifications.show({