From 51c46db1063a7b8ab5e3bc260a3e2f1d7db437ab Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Wed, 29 Oct 2025 17:06:39 +0100 Subject: [PATCH] Fix --- .../buttons/more-options-user-button.tsx | 2 +- web/components/notifications.tsx | 10 +++++++- web/components/profile/delete-yourself.tsx | 6 ++--- web/pages/settings.tsx | 23 +++++++++++-------- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/web/components/buttons/more-options-user-button.tsx b/web/components/buttons/more-options-user-button.tsx index 091bd5e5..79632083 100644 --- a/web/components/buttons/more-options-user-button.tsx +++ b/web/components/buttons/more-options-user-button.tsx @@ -104,7 +104,7 @@ export function MoreOptionsUserButton(props: { user: User }) { title: 'Delete Account', content: (
- +
), }, diff --git a/web/components/notifications.tsx b/web/components/notifications.tsx index 85bc3076..b1c31481 100644 --- a/web/components/notifications.tsx +++ b/web/components/notifications.tsx @@ -9,11 +9,19 @@ import {debounce} from "lodash"; import {api} from "web/lib/api"; import {MultiSelectAnswers} from "web/components/answers/answer-compatibility-question-content"; import {usePrivateUser} from "web/hooks/use-user"; +import {PrivateUser} from "common/user"; +import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator"; export const NotificationSettings = () => { const privateUser = usePrivateUser() - if (!privateUser) return null + if (!privateUser) return + return +} +function LoadedNotificationSettings(props: { + privateUser: PrivateUser, +}) { + const {privateUser} = props const [prefs, setPrefs] = usePersistentInMemoryState( privateUser.notificationPreferences, diff --git a/web/components/profile/delete-yourself.tsx b/web/components/profile/delete-yourself.tsx index 5e7dd678..fd2cae69 100644 --- a/web/components/profile/delete-yourself.tsx +++ b/web/components/profile/delete-yourself.tsx @@ -8,9 +8,7 @@ import {Input} from '../widgets/input' import {Title} from '../widgets/title' import {deleteAccount} from "web/lib/util/delete"; -export function DeleteYourselfButton(props: { username: string }) { - const {username} = props - +export function DeleteYourselfButton() { const [deleteAccountConfirmation, setDeleteAccountConfirmation] = useState('') return ( @@ -29,7 +27,7 @@ export function DeleteYourselfButton(props: { username: string }) { onSubmitWithSuccess={async () => { if (deleteAccountConfirmation == 'delete my account') { toast - .promise(deleteAccount(username), { + .promise(deleteAccount(), { loading: 'Deleting account...', success: () => { router.push('/') diff --git a/web/pages/settings.tsx b/web/pages/settings.tsx index 72fe54b2..8bd22a37 100644 --- a/web/pages/settings.tsx +++ b/web/pages/settings.tsx @@ -9,22 +9,21 @@ import toast from "react-hot-toast"; import {deleteAccount} from "web/lib/util/delete"; import router from "next/router"; import {Button} from "web/components/buttons/button"; -import {getAuth, sendEmailVerification, sendPasswordResetEmail, User} from 'firebase/auth'; +import {getAuth, sendEmailVerification, sendPasswordResetEmail} from 'firebase/auth'; import {auth} from "web/lib/firebase/users"; import {NotificationSettings} from "web/components/notifications"; import ThemeIcon from "web/components/theme-icon"; +import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator"; export default function NotificationsPage() { useRedirectIfSignedOut() - const privateUser = usePrivateUser() - const user = auth.currentUser return ( Settings }, + {title: 'General', content: }, {title: 'Notifications', content: }, ]} trackingName={'settings page'} @@ -33,12 +32,18 @@ export default function NotificationsPage() { ) } -const GeneralSettings = (props: { - privateUser: PrivateUser | null | undefined, - user: User | null, +export const GeneralSettings = () => { + const privateUser = usePrivateUser() + if (!privateUser) return + return +} + +const LoadedGeneralSettings = (props: { + privateUser: PrivateUser, }) => { - const {privateUser, user} = props - if (!privateUser || !user) return null + const {privateUser} = props + const user = auth.currentUser + if (!user) return null const handleDeleteAccount = async () => { const confirmed = confirm(