From b2978096fdccdbc73d0f6a34ada44d9661f704cc Mon Sep 17 00:00:00 2001 From: Calum Date: Fri, 11 Jul 2025 17:13:38 +0100 Subject: [PATCH] fix: shouldShow issues --- .../src/components/ui/ProjectMemberHeader.vue | 37 +++---------------- packages/moderation/types/nags.ts | 3 +- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/apps/frontend/src/components/ui/ProjectMemberHeader.vue b/apps/frontend/src/components/ui/ProjectMemberHeader.vue index 917a87d06..74077a008 100644 --- a/apps/frontend/src/components/ui/ProjectMemberHeader.vue +++ b/apps/frontend/src/components/ui/ProjectMemberHeader.vue @@ -29,30 +29,6 @@

Publishing checklist

-
- Progress: -
-
- - -
-
-
-
+
- + (() => ({ const applicableNags = computed(() => { return nags.filter((nag) => { - return !nag.shouldShow || nag.shouldShow(nagContext.value); + return nag.shouldShow(nagContext.value); }); }); const isNagComplete = (nag: Nag): boolean => { const context = nagContext.value; + return !nag.shouldShow(context); }; const visibleNags = computed(() => { @@ -179,9 +156,7 @@ const visibleNags = computed(() => { }); const shouldShowLink = (nag: Nag): boolean => { - if (!nag.link) return false; - if (!nag.link.shouldShow) return true; - return nag.link.shouldShow(nagContext.value); + return nag.link?.shouldShow ? nag.link.shouldShow(nagContext.value) : false; }; const getDefaultIcon = (status: NagStatus): Component => { @@ -212,7 +187,7 @@ const getStatusTooltip = (status: NagStatus): string => { const showInvitation = computed(() => { if (props.allMembers && props.auth) { - const member = props.allMembers.find((x) => x.user.id === props.auth.user.id); + const member = props.allMembers.find((x) => x?.user?.id === props.auth.user.id); return !!member && !member.accepted; } return false; diff --git a/packages/moderation/types/nags.ts b/packages/moderation/types/nags.ts index 0a48f8951..0e8075c8c 100644 --- a/packages/moderation/types/nags.ts +++ b/packages/moderation/types/nags.ts @@ -78,10 +78,11 @@ export interface Nag { * If not specified it will use the default icon associated with the nag status. */ icon?: FunctionalComponent + /** * A function that determines whether the nag should be shown based on the context. */ - shouldShow?: (context: NagContext) => boolean + shouldShow: (context: NagContext) => boolean /** * An optional link associated with the nag. * If provided, it should be displayed alongside the nag.