-
+
(() => ({
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.