Skip to content

Commit 51c46db

Browse files
committed
Fix
1 parent 64c1817 commit 51c46db

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

web/components/buttons/more-options-user-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function MoreOptionsUserButton(props: { user: User }) {
104104
title: 'Delete Account',
105105
content: (
106106
<div className="flex min-h-[200px] items-center justify-center p-4">
107-
<DeleteYourselfButton username={user.username} />
107+
<DeleteYourselfButton/>
108108
</div>
109109
),
110110
},

web/components/notifications.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ import {debounce} from "lodash";
99
import {api} from "web/lib/api";
1010
import {MultiSelectAnswers} from "web/components/answers/answer-compatibility-question-content";
1111
import {usePrivateUser} from "web/hooks/use-user";
12+
import {PrivateUser} from "common/user";
13+
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator";
1214

1315
export const NotificationSettings = () => {
1416
const privateUser = usePrivateUser()
15-
if (!privateUser) return null
17+
if (!privateUser) return <CompassLoadingIndicator/>
18+
return <LoadedNotificationSettings privateUser={privateUser}/>
19+
}
1620

21+
function LoadedNotificationSettings(props: {
22+
privateUser: PrivateUser,
23+
}) {
24+
const {privateUser} = props
1725
const [prefs, setPrefs] =
1826
usePersistentInMemoryState<notification_preferences>(
1927
privateUser.notificationPreferences,

web/components/profile/delete-yourself.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {Input} from '../widgets/input'
88
import {Title} from '../widgets/title'
99
import {deleteAccount} from "web/lib/util/delete";
1010

11-
export function DeleteYourselfButton(props: { username: string }) {
12-
const {username} = props
13-
11+
export function DeleteYourselfButton() {
1412
const [deleteAccountConfirmation, setDeleteAccountConfirmation] = useState('')
1513

1614
return (
@@ -29,7 +27,7 @@ export function DeleteYourselfButton(props: { username: string }) {
2927
onSubmitWithSuccess={async () => {
3028
if (deleteAccountConfirmation == 'delete my account') {
3129
toast
32-
.promise(deleteAccount(username), {
30+
.promise(deleteAccount(), {
3331
loading: 'Deleting account...',
3432
success: () => {
3533
router.push('/')

web/pages/settings.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ import toast from "react-hot-toast";
99
import {deleteAccount} from "web/lib/util/delete";
1010
import router from "next/router";
1111
import {Button} from "web/components/buttons/button";
12-
import {getAuth, sendEmailVerification, sendPasswordResetEmail, User} from 'firebase/auth';
12+
import {getAuth, sendEmailVerification, sendPasswordResetEmail} from 'firebase/auth';
1313
import {auth} from "web/lib/firebase/users";
1414
import {NotificationSettings} from "web/components/notifications";
1515
import ThemeIcon from "web/components/theme-icon";
16+
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator";
1617

1718
export default function NotificationsPage() {
1819
useRedirectIfSignedOut()
19-
const privateUser = usePrivateUser()
20-
const user = auth.currentUser
2120
return (
2221
<PageBase trackPageView={'settings page'} className={'mx-4'}>
2322
<NoSEO/>
2423
<Title>Settings</Title>
2524
<UncontrolledTabs
2625
tabs={[
27-
{title: 'General', content: <GeneralSettings privateUser={privateUser} user={user}/>},
26+
{title: 'General', content: <GeneralSettings/>},
2827
{title: 'Notifications', content: <NotificationSettings/>},
2928
]}
3029
trackingName={'settings page'}
@@ -33,12 +32,18 @@ export default function NotificationsPage() {
3332
)
3433
}
3534

36-
const GeneralSettings = (props: {
37-
privateUser: PrivateUser | null | undefined,
38-
user: User | null,
35+
export const GeneralSettings = () => {
36+
const privateUser = usePrivateUser()
37+
if (!privateUser) return <CompassLoadingIndicator/>
38+
return <LoadedGeneralSettings privateUser={privateUser}/>
39+
}
40+
41+
const LoadedGeneralSettings = (props: {
42+
privateUser: PrivateUser,
3943
}) => {
40-
const {privateUser, user} = props
41-
if (!privateUser || !user) return null
44+
const {privateUser} = props
45+
const user = auth.currentUser
46+
if (!user) return null
4247

4348
const handleDeleteAccount = async () => {
4449
const confirmed = confirm(

0 commit comments

Comments
 (0)