Skip to content

Commit 039bef2

Browse files
chore(table): address PR review nits on tables.ts
- Merge duplicate JSDoc on snapshotAndMutateRows into a single block - Remove unused useQueryClient() calls from useTableRows and useInfiniteTableRows (leftover from polling-era code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d3428ff commit 039bef2

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

apps/sim/hooks/queries/tables.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ export function useTableRows({
225225
includeTotal,
226226
enabled = true,
227227
}: TableRowsParams & { enabled?: boolean }) {
228-
const queryClient = useQueryClient()
229228
const paramsKey = JSON.stringify({
230229
limit,
231230
offset,
@@ -259,7 +258,6 @@ export function useInfiniteTableRows({
259258
sort,
260259
enabled = true,
261260
}: InfiniteTableRowsParams) {
262-
const queryClient = useQueryClient()
263261
const paramsKey = JSON.stringify({
264262
pageSize,
265263
filter: filter ?? null,
@@ -1022,18 +1020,18 @@ function isInfiniteRowsCache(value: unknown): value is InfiniteRowsCache {
10221020
}
10231021

10241022
/**
1025-
* Walks every cached row-list under `tableId`, applies `transform` to each row,
1026-
* and snapshots the originals for rollback.
1023+
* Walks every cached query under `rowsRoot(tableId)` and applies `transform`
1024+
* to each row. Handles both cache shapes — the single-page `TableRowsResponse`
1025+
* and the infinite-query `{ pages, pageParams }`. `transform(row)` returns
1026+
* the next row to write, or `null` to leave it.
1027+
*
1028+
* Returns the list of `[queryKey, prior data]` entries so optimistic-update
1029+
* callers can roll back. SSE patchers can ignore the return value.
10271030
*
1028-
* Handles both cache shapes: the single-page `TableRowsResponse` and the
1029-
* infinite-query `{ pages, pageParams }`. `transform(row)` returns the next
1030-
* row to write, or `null` to leave it. The common pattern is "matching cells
1031-
* flip state, others are skipped".
1031+
* `cancelInFlight` defaults to true (the optimistic-update contract) but SSE
1032+
* patchers pass `false` so live cell updates don't kick the row query off the
1033+
* network.
10321034
*/
1033-
/** Walks every cached query under `rowsRoot(tableId)` and applies `transform`
1034-
* to each row. Transform returns the new row or `null` to skip. Returns the
1035-
* list of [queryKey, prior data] entries so optimistic-update callers can
1036-
* roll back. SSE patchers can ignore the return value. */
10371035
export async function snapshotAndMutateRows(
10381036
queryClient: ReturnType<typeof useQueryClient>,
10391037
tableId: string,

0 commit comments

Comments
 (0)