Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darkruby501 committed Jun 10, 2024
1 parent 8a2f1f1 commit 3bdc7d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions packages/lesswrong/components/users/FollowUserButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ export const FollowUserButton = ({user, classes}: {
hideFlashes: true,
});

const onSubscribeWithDM = async (ev: React.MouseEvent<Element, MouseEvent>) => {
const onSubscribeNullSafe = onSubscribe ?? (() => Promise.resolve())

await onSubscribeNullSafe(ev);
return await sendNewFollowDM({ variables: { eventType: "newFollowSubscription" } });
}

const [subscribed, toggleSubscribed] = useOptimisticToggle(
isSubscribed ?? false,
onSubscribe ?? (() => {}),
onSubscribeWithDM
);

const [sendNewFollowDM] = useMutation(gql`
Expand All @@ -47,7 +54,6 @@ export const FollowUserButton = ({user, classes}: {

const handleSubscribe = (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
void toggleSubscribed(ev);
void sendNewFollowDM({variables: {eventType: "newFollowSubscription"}})
captureEvent("followUserButtonClick", {subcribedToUser: user._id, subscribed: !subscribed})
}

Expand Down
10 changes: 5 additions & 5 deletions packages/lesswrong/server/resolvers/conversationResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const followSubscriptionStartDate = forumSelect({
})

const getTriggeredDmContents = (eventType: DmTriggeringEvent) => {
const adminEmail = adminAccountSetting.get()?.email ?? "";
const adminEmail = adminAccountSetting.get()?.email ?? "";

switch (eventType) {
case "newFollowSubscription":
Expand Down Expand Up @@ -77,10 +77,10 @@ defineMutation({
createdAt: {$gt: followSubscriptionStartDate}
}).count();

// if (numUsersFollows > 1) {
// // already has followed and received a DM
// return false;
// }
if (numUsersFollows > 1) {
// already has followed and received a DM
return false;
}
}

const { title, message } = getTriggeredDmContents(eventType);
Expand Down

0 comments on commit 3bdc7d0

Please sign in to comment.