Skip to content

Commit ee992ea

Browse files
kevinortiz43claude
andcommitted
Block incomplete profiles from creating discussions
Empty profiles could start discussion threads. Gate the "New post" action behind the existing ProfileIncompleteDialog (same pattern as events/messages/friend requests), shown when the profile is incomplete. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 503a61d commit ee992ea

3 files changed

Lines changed: 32 additions & 9 deletions

File tree

app/web/components/ProfileIncompleteDialog/ProfileIncompleteDialog.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ interface ProfileIncompleteDialogProps {
2121
| "send_message"
2222
| "send_request"
2323
| "create_public_trip"
24-
| "send_friend_request";
24+
| "send_friend_request"
25+
| "create_discussion";
2526
}
2627

2728
export default function ProfileIncompleteDialog({
@@ -70,9 +71,6 @@ export default function ProfileIncompleteDialog({
7071
<Button component={Link} href={routeToEditProfile()}>
7172
{t("profile:complete_profile_dialog.edit_profile_button")}
7273
</Button>
73-
<Button component={Link} href={routeToEditProfile()}>
74-
{t("dashboard:complete_profile_dialog.edit_profile_button")}
75-
</Button>
7674
</DialogActions>
7775
</Dialog>
7876
);

app/web/features/communities/discussions/DiscussionsListPage.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import Alert from "components/Alert";
33
import Button from "components/Button";
44
import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
55
import { EmailIcon } from "components/Icons";
6+
import ProfileIncompleteDialog from "components/ProfileIncompleteDialog/ProfileIncompleteDialog";
67
import TextBody from "components/TextBody";
8+
import useAccountInfo from "features/auth/useAccountInfo";
79
import { SectionTitle } from "features/communities/CommunityPage";
810
import { useListDiscussions } from "features/communities/hooks";
911
import { useTranslation } from "i18n";
1012
import { COMMUNITIES } from "i18n/namespaces";
1113
import { Community } from "proto/communities_pb";
12-
import { useState } from "react";
14+
import { useEffect, useState } from "react";
1315
import { theme } from "theme";
1416
import hasAtLeastOnePage from "utils/hasAtLeastOnePage";
1517

@@ -62,10 +64,29 @@ export default function DiscussionsListPage({
6264
}) {
6365
const { t } = useTranslation([COMMUNITIES]);
6466

67+
const { data: accountInfo } = useAccountInfo();
6568
const hash = typeof window !== "undefined" ? window.location.hash : "";
6669
const [isCreatingNewPost, setIsCreatingNewPost] = useState(
6770
hash.includes("new"),
6871
);
72+
const [profileDialogOpen, setProfileDialogOpen] = useState(false);
73+
74+
// If #new hash auto-opened the form but profile is incomplete, show dialog instead
75+
useEffect(() => {
76+
if (accountInfo && !accountInfo.profileComplete && isCreatingNewPost) {
77+
setIsCreatingNewPost(false);
78+
setProfileDialogOpen(true);
79+
}
80+
}, [accountInfo, isCreatingNewPost]);
81+
82+
const handleNewPostClick = () => {
83+
if (accountInfo !== undefined && !accountInfo.profileComplete) {
84+
setProfileDialogOpen(true);
85+
} else {
86+
setIsCreatingNewPost(true);
87+
}
88+
};
89+
6990
const {
7091
isLoading: isDiscussionsLoading,
7192
isFetching: isDiscussionsFetching,
@@ -80,6 +101,11 @@ export default function DiscussionsListPage({
80101

81102
return (
82103
<>
104+
<ProfileIncompleteDialog
105+
open={profileDialogOpen}
106+
onClose={() => setProfileDialogOpen(false)}
107+
attempted_action="create_discussion"
108+
/>
83109
<StyledDiscussionsHeader>
84110
<SectionTitle icon={<EmailIcon />}>
85111
{t("communities:discussions_title")}
@@ -90,9 +116,7 @@ export default function DiscussionsListPage({
90116
)}
91117
<Collapse in={!isCreatingNewPost}>
92118
<StyledNewPostButtonContainer>
93-
<StyledCreateResourceButton
94-
onClick={() => setIsCreatingNewPost(true)}
95-
>
119+
<StyledCreateResourceButton onClick={handleNewPostClick}>
96120
{t("communities:new_post_label")}
97121
</StyledCreateResourceButton>
98122
{isRefetching && <CenteredSpinner />}

app/web/features/profile/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@
345345
"send_message": "send a message",
346346
"send_friend_request": "send a friend request",
347347
"create_event": "create an event",
348-
"create_public_trip": "create a public trip"
348+
"create_public_trip": "create a public trip",
349+
"create_discussion": "create a discussion"
349350
},
350351
"edit_profile_button": "Edit your profile now",
351352
"cancel_button": "Never mind"

0 commit comments

Comments
 (0)