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