diff --git a/src/core/apollo/generated/apollo-helpers.ts b/src/core/apollo/generated/apollo-helpers.ts index b717c2e282..4849340800 100644 --- a/src/core/apollo/generated/apollo-helpers.ts +++ b/src/core/apollo/generated/apollo-helpers.ts @@ -1557,6 +1557,7 @@ export type InAppNotificationCommunityNewMemberFieldPolicy = { export type InAppNotificationUserMentionedKeySpecifier = ( | 'category' | 'comment' + | 'commentOriginName' | 'commentUrl' | 'contributorType' | 'id' @@ -1570,6 +1571,7 @@ export type InAppNotificationUserMentionedKeySpecifier = ( export type InAppNotificationUserMentionedFieldPolicy = { category?: FieldPolicy | FieldReadFunction; comment?: FieldPolicy | FieldReadFunction; + commentOriginName?: FieldPolicy | FieldReadFunction; commentUrl?: FieldPolicy | FieldReadFunction; contributorType?: FieldPolicy | FieldReadFunction; id?: FieldPolicy | FieldReadFunction; diff --git a/src/core/apollo/generated/apollo-hooks.ts b/src/core/apollo/generated/apollo-hooks.ts index cc22b1193b..5e8d5184e7 100644 --- a/src/core/apollo/generated/apollo-hooks.ts +++ b/src/core/apollo/generated/apollo-hooks.ts @@ -3169,6 +3169,7 @@ export const InAppNotificationUserMentionedFragmentDoc = gql` } commentUrl comment + commentOriginName contributorType } ${VisualUriFragmentDoc} diff --git a/src/core/apollo/generated/graphql-schema.ts b/src/core/apollo/generated/graphql-schema.ts index 4c2273d540..957920f0f8 100644 --- a/src/core/apollo/generated/graphql-schema.ts +++ b/src/core/apollo/generated/graphql-schema.ts @@ -2605,6 +2605,8 @@ export type InAppNotificationUserMentioned = InAppNotification & { category: InAppNotificationCategory; /** The comment that the contributor was mentioned in. */ comment: Scalars['String']; + /** The display name of the resource where the comment was created. */ + commentOriginName: Scalars['String']; /** The url of the resource where the comment was created. */ commentUrl: Scalars['String']; /** The type of the Contributor that joined. */ @@ -28000,6 +28002,7 @@ export type InAppNotificationsQuery = { triggeredAt: Date; commentUrl: string; comment: string; + commentOriginName: string; contributorType: CommunityContributorType; triggeredBy: | { @@ -28210,6 +28213,7 @@ export type InAppNotificationUserMentionedFragment = { __typename?: 'InAppNotificationUserMentioned'; commentUrl: string; comment: string; + commentOriginName: string; contributorType: CommunityContributorType; triggeredBy: | { diff --git a/src/main/inAppNotifications/graphql/InAppNotificationsFragments.graphql b/src/main/inAppNotifications/graphql/InAppNotificationsFragments.graphql index d41db12ca2..30bf962e8b 100644 --- a/src/main/inAppNotifications/graphql/InAppNotificationsFragments.graphql +++ b/src/main/inAppNotifications/graphql/InAppNotificationsFragments.graphql @@ -91,5 +91,6 @@ fragment InAppNotificationUserMentioned on InAppNotificationUserMentioned { } commentUrl comment + commentOriginName contributorType } diff --git a/src/main/inAppNotifications/useInAppNotifications.ts b/src/main/inAppNotifications/useInAppNotifications.ts index 363a67af4e..b860e6914a 100644 --- a/src/main/inAppNotifications/useInAppNotifications.ts +++ b/src/main/inAppNotifications/useInAppNotifications.ts @@ -85,6 +85,7 @@ export interface InAppNotificationProps { }; comment?: string; commentUrl?: string; + commentOriginName?: string; } export const useInAppNotifications = () => { diff --git a/src/main/inAppNotifications/views/CollaborationCalloutPublishedView.tsx b/src/main/inAppNotifications/views/CollaborationCalloutPublishedView.tsx index 9c1dea912a..8b946fad77 100644 --- a/src/main/inAppNotifications/views/CollaborationCalloutPublishedView.tsx +++ b/src/main/inAppNotifications/views/CollaborationCalloutPublishedView.tsx @@ -2,6 +2,8 @@ import { useTranslation } from 'react-i18next'; import { InAppNotificationProps } from '../useInAppNotifications'; import { InAppNotificationBaseView, InAppNotificationBaseViewProps } from './InAppNotificationBaseView'; import { useMemo } from 'react'; +import { getChildJourneyTypeName } from '@/domain/shared/utils/spaceLevel'; +import { SpaceLevel } from '@/core/apollo/generated/graphql-schema'; export const CollaborationCalloutPublishedView = ({ id, @@ -24,7 +26,7 @@ export const CollaborationCalloutPublishedView = ({ const notificationTextValues = { defaultValue: '', spaceName: space?.profile?.displayName, - spaceType: space?.level, + spaceType: t(`common.${getChildJourneyTypeName({ level: space?.level ?? SpaceLevel.Space })}`), calloutName: callout?.framing?.profile?.displayName, calloutType: calloutType, contributorName: triggeredBy?.profile?.displayName, @@ -48,5 +50,15 @@ export const CollaborationCalloutPublishedView = ({ }; }, [id, state, space, callout, triggeredBy, triggeredAt, t]); + // do not display notification if these are missing + if ( + !callout || + !callout.framing?.profile?.displayName || + !callout?.framing?.profile?.url || + !triggeredBy?.profile?.displayName + ) { + return null; + } + return ; }; diff --git a/src/main/inAppNotifications/views/CommunicationUserMentionView.tsx b/src/main/inAppNotifications/views/CommunicationUserMentionView.tsx index d09381a86b..22ba53afb3 100644 --- a/src/main/inAppNotifications/views/CommunicationUserMentionView.tsx +++ b/src/main/inAppNotifications/views/CommunicationUserMentionView.tsx @@ -7,17 +7,17 @@ export const CommunicationUserMentionView = ({ type, state, space, - callout, triggeredBy, triggeredAt, comment, commentUrl, + commentOriginName, }: InAppNotificationProps) => { const notification: InAppNotificationBaseViewProps = useMemo(() => { const notificationTextValues = { defaultValue: '', commenterName: triggeredBy?.profile?.displayName, - calloutName: callout?.framing?.profile?.displayName, + calloutName: commentOriginName, comment, }; @@ -37,7 +37,12 @@ export const CommunicationUserMentionView = ({ triggeredAt: triggeredAt, values: notificationTextValues, }; - }, [id, state, space, triggeredBy, callout, triggeredAt, comment, commentUrl]); + }, [id, state, space, triggeredBy, commentOriginName, triggeredAt, comment, commentUrl]); + + // do not display notification if these are missing + if (!commentOriginName || !commentUrl || !triggeredBy?.profile?.displayName) { + return null; + } return ; }; diff --git a/src/main/inAppNotifications/views/CommunityNewMemberAdminView.tsx b/src/main/inAppNotifications/views/CommunityNewMemberAdminView.tsx index 7a7c9996e4..e705f3e627 100644 --- a/src/main/inAppNotifications/views/CommunityNewMemberAdminView.tsx +++ b/src/main/inAppNotifications/views/CommunityNewMemberAdminView.tsx @@ -26,5 +26,10 @@ export const CommunityNewMemberAdminView = ({ id, state, space, triggeredAt, act }; }, [id, state, space, triggeredAt, actor]); + // do not display notification if these are missing + if (!actor?.profile?.displayName || !space?.profile?.displayName) { + return null; + } + return ; }; diff --git a/src/main/inAppNotifications/views/CommunityNewMemberView.tsx b/src/main/inAppNotifications/views/CommunityNewMemberView.tsx index e9d2d48f57..bca433b6c2 100644 --- a/src/main/inAppNotifications/views/CommunityNewMemberView.tsx +++ b/src/main/inAppNotifications/views/CommunityNewMemberView.tsx @@ -24,5 +24,10 @@ export const CommunityNewMemberView = ({ id, type, state, space, triggeredAt }: }; }, [id, state, space, triggeredAt]); + // do not display notification if these are missing + if (!space?.profile?.displayName) { + return null; + } + return ; };