Skip to content

Commit 81433e3

Browse files
authored
feat(shared): remove notification cta v2 flag (#5893)
1 parent 7c74988 commit 81433e3

12 files changed

Lines changed: 72 additions & 789 deletions

File tree

packages/shared/src/components/cards/entity/EnableNotificationsCta.tsx

Lines changed: 0 additions & 75 deletions
This file was deleted.

packages/shared/src/components/cards/entity/SourceEntityCard.tsx

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import React from 'react';
22
import Link from '../../utilities/Link';
33
import EntityCard from './EntityCard';
44
import {
@@ -13,23 +13,11 @@ import CustomFeedOptionsMenu from '../../CustomFeedOptionsMenu';
1313
import { ButtonVariant } from '../../buttons/Button';
1414
import { Separator } from '../common/common';
1515
import EntityDescription from './EntityDescription';
16-
import EnableNotificationsCta from './EnableNotificationsCta';
1716
import useSourceMenuProps from '../../../hooks/useSourceMenuProps';
18-
import {
19-
ContentPreferenceStatus,
20-
ContentPreferenceType,
21-
} from '../../../graphql/contentPreference';
22-
import {
23-
NotificationCtaPlacement,
24-
NotificationPromptSource,
25-
TargetType,
26-
} from '../../../lib/log';
17+
import { ContentPreferenceType } from '../../../graphql/contentPreference';
2718
import useShowFollowAction from '../../../hooks/useShowFollowAction';
2819
import { FollowButton } from '../../contentPreference/FollowButton';
2920
import { useContentPreferenceStatusQuery } from '../../../hooks/contentPreference/useContentPreferenceStatusQuery';
30-
import { useContentPreference } from '../../../hooks/contentPreference/useContentPreference';
31-
import { useSourceActionsNotify } from '../../../hooks/source/useSourceActionsNotify';
32-
import { useNotificationCtaExperiment } from '../../../hooks/notifications/useNotificationCtaExperiment';
3321

3422
type SourceEntityCardProps = {
3523
source: SourceTooltip;
@@ -49,68 +37,12 @@ const SourceEntityCard = ({ source, className }: SourceEntityCardProps) => {
4937
id: sourceId,
5038
entity: ContentPreferenceType.Source,
5139
});
52-
const [showNotificationCta, setShowNotificationCta] = useState(false);
53-
const { isEnabled: isNotificationCtaExperimentEnabled } =
54-
useNotificationCtaExperiment({
55-
shouldEvaluate: showNotificationCta,
56-
});
57-
const { subscribe } = useContentPreference();
58-
const prevStatusRef = useRef(contentPreference?.status);
5940
const menuProps = useSourceMenuProps({ source });
60-
const { haveNotificationsOn, onNotify } = useSourceActionsNotify({
61-
source,
62-
});
63-
64-
const currentStatus = contentPreference?.status;
65-
const isNowFollowing =
66-
currentStatus === ContentPreferenceStatus.Follow ||
67-
currentStatus === ContentPreferenceStatus.Subscribed;
68-
const wasFollowing =
69-
prevStatusRef.current === ContentPreferenceStatus.Follow ||
70-
prevStatusRef.current === ContentPreferenceStatus.Subscribed;
71-
const shouldRenderNotificationCta =
72-
isNotificationCtaExperimentEnabled &&
73-
showNotificationCta &&
74-
!haveNotificationsOn;
75-
76-
useEffect(() => {
77-
if (currentStatus === prevStatusRef.current) {
78-
return;
79-
}
80-
81-
prevStatusRef.current = currentStatus;
82-
83-
if (isNowFollowing && !wasFollowing) {
84-
setShowNotificationCta(true);
85-
return;
86-
}
87-
88-
if (!isNowFollowing && wasFollowing) {
89-
setShowNotificationCta(false);
90-
}
91-
}, [currentStatus, isNowFollowing, wasFollowing]);
9241

9342
if (!source?.id || !source.name || !source.image || !source.permalink) {
9443
return null;
9544
}
9645

97-
const handleTurnOn = async () => {
98-
if (!source?.id) {
99-
throw new Error('Cannot subscribe to notifications without source id');
100-
}
101-
102-
if (currentStatus !== ContentPreferenceStatus.Subscribed) {
103-
await subscribe({
104-
id: source.id,
105-
entity: ContentPreferenceType.Source,
106-
entityName: source.name ?? source.id,
107-
});
108-
}
109-
110-
await onNotify();
111-
setShowNotificationCta(false);
112-
};
113-
11446
return (
11547
<EntityCard
11648
permalink={source.permalink}
@@ -174,17 +106,6 @@ const SourceEntityCard = ({ source, className }: SourceEntityCardProps) => {
174106
{largeNumberFormat(source.flags?.totalUpvotes ?? 0) || 0} Upvotes
175107
</Typography>
176108
</div>
177-
{shouldRenderNotificationCta && (
178-
<EnableNotificationsCta
179-
onEnable={handleTurnOn}
180-
analytics={{
181-
placement: NotificationCtaPlacement.SourceCard,
182-
targetType: TargetType.Source,
183-
targetId: source.id,
184-
source: NotificationPromptSource.SourceSubscribe,
185-
}}
186-
/>
187-
)}
188109
</div>
189110
</EntityCard>
190111
);

packages/shared/src/components/cards/entity/SquadEntityCard.tsx

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from 'react';
1+
import React from 'react';
22
import Link from '../../utilities/Link';
33
import {
44
Typography,
@@ -7,11 +7,6 @@ import {
77
TypographyType,
88
} from '../../typography/Typography';
99
import type { Origin } from '../../../lib/log';
10-
import {
11-
NotificationCtaPlacement,
12-
NotificationPromptSource,
13-
TargetType,
14-
} from '../../../lib/log';
1510
import { largeNumberFormat } from '../../../lib';
1611
import { SquadActionButton } from '../../squads/SquadActionButton';
1712
import { SourceIcon } from '../../icons';
@@ -24,14 +19,10 @@ import EntityDescription from './EntityDescription';
2419
import EntityCard from './EntityCard';
2520
import { ContentPreferenceType } from '../../../graphql/contentPreference';
2621
import useShowFollowAction from '../../../hooks/useShowFollowAction';
27-
import EnableNotificationsCta from './EnableNotificationsCta';
28-
import { useSourceActionsNotify } from '../../../hooks/source/useSourceActionsNotify';
29-
import { useNotificationCtaExperiment } from '../../../hooks/notifications/useNotificationCtaExperiment';
3022

3123
type SquadEntityCardProps = {
3224
handle: string;
3325
origin: Origin;
34-
showNotificationCtaOnJoin?: boolean;
3526
className?: {
3627
container?: string;
3728
};
@@ -40,56 +31,21 @@ type SquadEntityCardProps = {
4031
const SquadEntityCard = ({
4132
handle,
4233
origin,
43-
showNotificationCtaOnJoin = false,
4434
className,
4535
}: SquadEntityCardProps) => {
4636
const { squad } = useSquad({ handle });
47-
const [showNotificationCta, setShowNotificationCta] = useState(false);
48-
const { isEnabled: isNotificationCtaExperimentEnabled } =
49-
useNotificationCtaExperiment({
50-
shouldEvaluate: showNotificationCta,
51-
});
52-
const wasSquadMemberRef = useRef(!!squad?.currentMember);
5337
const { isLoading } = useShowFollowAction({
5438
entityId: squad?.id ?? '',
5539
entityType: ContentPreferenceType.Source,
5640
});
57-
const { haveNotificationsOn, onNotify } = useSourceActionsNotify({
58-
source: squad,
59-
});
60-
61-
const isSquadMember = !!squad?.currentMember;
62-
const shouldRenderNotificationCta =
63-
isNotificationCtaExperimentEnabled &&
64-
showNotificationCta &&
65-
!haveNotificationsOn;
66-
67-
useEffect(() => {
68-
if (
69-
showNotificationCtaOnJoin &&
70-
isSquadMember &&
71-
!wasSquadMemberRef.current &&
72-
!haveNotificationsOn
73-
) {
74-
setShowNotificationCta(true);
75-
} else if (!isSquadMember) {
76-
setShowNotificationCta(false);
77-
}
78-
79-
wasSquadMemberRef.current = isSquadMember;
80-
}, [haveNotificationsOn, isSquadMember, showNotificationCtaOnJoin]);
81-
82-
const handleEnableNotifications = async () => {
83-
await onNotify();
84-
setShowNotificationCta(false);
85-
};
8641

8742
if (!squad?.id || !squad.name || !squad.image || !squad.permalink) {
8843
return null;
8944
}
9045

9146
const { description, name, image, membersCount, flags, permalink } =
9247
squad || {};
48+
9349
return (
9450
<EntityCard
9551
permalink={permalink}
@@ -162,17 +118,6 @@ const SquadEntityCard = ({
162118
{largeNumberFormat(flags?.totalUpvotes ?? 0)} Upvotes
163119
</Typography>
164120
</div>
165-
{shouldRenderNotificationCta && (
166-
<EnableNotificationsCta
167-
onEnable={handleEnableNotifications}
168-
analytics={{
169-
placement: NotificationCtaPlacement.SquadCard,
170-
targetType: TargetType.Source,
171-
targetId: squad.id,
172-
source: NotificationPromptSource.SourceSubscribe,
173-
}}
174-
/>
175-
)}
176121
</div>
177122
</EntityCard>
178123
);

0 commit comments

Comments
 (0)