fix: avoid Convex skip sentinel in queries
This commit is contained in:
parent
3880ff57bd
commit
3de7eccaa8
32 changed files with 131 additions and 125 deletions
|
|
@ -16,18 +16,16 @@ import { useAuth } from "@/lib/auth-client";
|
|||
|
||||
export function TicketDetailView({ id }: { id: string }) {
|
||||
const { convexUserId } = useAuth();
|
||||
const shouldSkip = !convexUserId;
|
||||
const t = useQuery(
|
||||
api.tickets.getById,
|
||||
shouldSkip
|
||||
? "skip"
|
||||
: {
|
||||
tenantId: DEFAULT_TENANT_ID,
|
||||
id: id as Id<"tickets">,
|
||||
viewerId: convexUserId as Id<"users">,
|
||||
}
|
||||
);
|
||||
const isLoading = shouldSkip || t === undefined;
|
||||
const canLoadTicket = Boolean(convexUserId);
|
||||
const queryArgs = canLoadTicket
|
||||
? {
|
||||
tenantId: DEFAULT_TENANT_ID,
|
||||
id: id as Id<"tickets">,
|
||||
viewerId: convexUserId as Id<"users">,
|
||||
}
|
||||
: undefined;
|
||||
const t = useQuery(canLoadTicket ? api.tickets.getById : undefined, queryArgs);
|
||||
const isLoading = !convexUserId || t === undefined;
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue