refactor(base): append remote row creates to cache instead of invalidating

This commit is contained in:
Philipinho
2026-04-18 13:15:49 +01:00
parent f5b19316af
commit 89638fb11d
@@ -123,7 +123,22 @@ export function useBaseSocket(baseId: string | undefined): void {
switch (event.operation) {
case "base:row:created": {
queryClient.invalidateQueries({ queryKey: ["base-rows", baseId] });
const e = event as BaseRowCreated;
queryClient.setQueriesData<InfiniteData<IPagination<IBaseRow>>>(
{ queryKey: ["base-rows", baseId] },
(old) => {
if (!old) return old;
const lastPageIndex = old.pages.length - 1;
return {
...old,
pages: old.pages.map((page, index) =>
index === lastPageIndex
? { ...page, items: [...page.items, e.row] }
: page,
),
};
},
);
break;
}
case "base:row:updated": {