fix: prevent card.byId validation errors when cardPublicId is empty
This commit is contained in:
@@ -8,6 +8,8 @@ export async function invalidateCard(
|
||||
utils: ReturnType<typeof api.useUtils>,
|
||||
cardPublicId: string,
|
||||
) {
|
||||
if (!cardPublicId || cardPublicId.length < 12) return;
|
||||
|
||||
await Promise.all([
|
||||
utils.card.byId.invalidate({ cardPublicId }),
|
||||
utils.card.getActivities.invalidate({ cardPublicId }),
|
||||
|
||||
@@ -363,7 +363,7 @@ const ActivityList = ({
|
||||
limit: ACTIVITIES_PAGE_SIZE,
|
||||
},
|
||||
{
|
||||
enabled: !!cardPublicId,
|
||||
enabled: !!cardPublicId && cardPublicId.length >= 12,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ export function CardRightPanel({ isTemplate }: { isTemplate?: boolean }) {
|
||||
? router.query.cardId[0]
|
||||
: router.query.cardId;
|
||||
|
||||
const { data: card } = api.card.byId.useQuery({
|
||||
cardPublicId: cardId ?? "",
|
||||
});
|
||||
const { data: card } = api.card.byId.useQuery(
|
||||
{ cardPublicId: cardId ?? "" },
|
||||
{ enabled: !!cardId && cardId.length >= 12 },
|
||||
);
|
||||
|
||||
const isCreator = card?.createdBy && session?.user.id === card.createdBy;
|
||||
const canEdit = canEditCard || isCreator;
|
||||
@@ -184,9 +185,10 @@ export default function CardPage({ isTemplate }: { isTemplate?: boolean }) {
|
||||
? router.query.cardId[0]
|
||||
: router.query.cardId;
|
||||
|
||||
const { data: card, isLoading } = api.card.byId.useQuery({
|
||||
cardPublicId: cardId ?? "",
|
||||
});
|
||||
const { data: card, isLoading } = api.card.byId.useQuery(
|
||||
{ cardPublicId: cardId ?? "" },
|
||||
{ enabled: !!cardId && cardId.length >= 12 },
|
||||
);
|
||||
|
||||
const isCreator = card?.createdBy && session?.user.id === card.createdBy;
|
||||
const canEdit = canEditCard || isCreator;
|
||||
|
||||
@@ -32,7 +32,7 @@ export function CardModal({
|
||||
cardPublicId: cardPublicId ?? "",
|
||||
},
|
||||
{
|
||||
enabled: isOpen && !!cardPublicId,
|
||||
enabled: isOpen && !!cardPublicId && cardPublicId.length >= 12,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user