@lotics/app-sdk 0.88.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/comments.d.ts
CHANGED
|
@@ -87,8 +87,11 @@ export interface CommentCountsState {
|
|
|
87
87
|
refetch: () => void;
|
|
88
88
|
}
|
|
89
89
|
export interface UseCommentCountsArgs {
|
|
90
|
-
/** The table whose per-record comment counts to read.
|
|
91
|
-
|
|
90
|
+
/** The table whose per-record comment counts to read. Read it off a row
|
|
91
|
+
* (`__source_table_id`) rather than pasting a `tbl_` id — a copy of the app
|
|
92
|
+
* runs over other tables. `undefined` (no row on screen yet) sends no
|
|
93
|
+
* request and answers `{}`. */
|
|
94
|
+
table_id: string | undefined;
|
|
92
95
|
}
|
|
93
96
|
/**
|
|
94
97
|
* Per-record comment counts for a whole table, as `{ record_id: count }` — for
|
|
@@ -96,7 +99,7 @@ export interface UseCommentCountsArgs {
|
|
|
96
99
|
* server-side `GROUP BY`. App-authority like {@link useComments}.
|
|
97
100
|
*
|
|
98
101
|
* ```tsx
|
|
99
|
-
* const { counts } = useCommentCounts({ table_id });
|
|
102
|
+
* const { counts } = useCommentCounts({ table_id: rows[0]?.__source_table_id });
|
|
100
103
|
* // counts[row.__source_record_id] ?? 0
|
|
101
104
|
* ```
|
|
102
105
|
*/
|
package/dist/src/comments.js
CHANGED
|
@@ -170,7 +170,7 @@ export function useComments(args) {
|
|
|
170
170
|
* server-side `GROUP BY`. App-authority like {@link useComments}.
|
|
171
171
|
*
|
|
172
172
|
* ```tsx
|
|
173
|
-
* const { counts } = useCommentCounts({ table_id });
|
|
173
|
+
* const { counts } = useCommentCounts({ table_id: rows[0]?.__source_table_id });
|
|
174
174
|
* // counts[row.__source_record_id] ?? 0
|
|
175
175
|
* ```
|
|
176
176
|
*/
|
|
@@ -178,7 +178,7 @@ export function useCommentCounts(args) {
|
|
|
178
178
|
const { table_id } = args;
|
|
179
179
|
const { memberId, commentsEnabled, resolved } = useAppContext();
|
|
180
180
|
const available = memberId != null && commentsEnabled;
|
|
181
|
-
const swr = useSWR(available ? ["app-comment-counts", table_id] : null, () => rpc("comments.counts", { table_id }), { shouldRetryOnError: false });
|
|
181
|
+
const swr = useSWR(available && table_id !== undefined ? ["app-comment-counts", table_id] : null, () => rpc("comments.counts", { table_id }), { shouldRetryOnError: false });
|
|
182
182
|
const refetch = useCallback(() => {
|
|
183
183
|
void swr.mutate();
|
|
184
184
|
}, [swr]);
|
|
@@ -309,7 +309,9 @@ updateComment, deleteComment, refetch }`.
|
|
|
309
309
|
`useCommentCounts({ table_id })` → `{ counts, loading, error, available, refetch }` where `counts`
|
|
310
310
|
is `{ record_id: count }` for the whole table — row badges without shipping any comment content
|
|
311
311
|
(one server-side aggregate). Same gate and authority as `useComments`. `table_id` is the source
|
|
312
|
-
table's id
|
|
312
|
+
table's id: read it off a row of the query that renders the badges (`rows[0]?.__source_table_id`)
|
|
313
|
+
rather than pasting a `tbl_` id, which a copy of the app cannot carry. Pass `undefined` while no
|
|
314
|
+
row is on screen — no request is sent and `counts` is `{}`.
|
|
313
315
|
|
|
314
316
|
## Pairing with `@lotics/ui`
|
|
315
317
|
|