From aef1b1971e93709478ae7f3986698ad7c075b687 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 25 Jun 2025 16:06:44 +0300 Subject: [PATCH] tweak switch logic --- .../SubscribeProfileDialog.tsx | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/activity-notifications/SubscribeProfileDialog.tsx b/src/components/activity-notifications/SubscribeProfileDialog.tsx index 334faf8839..6188963b7c 100644 --- a/src/components/activity-notifications/SubscribeProfileDialog.tsx +++ b/src/components/activity-notifications/SubscribeProfileDialog.tsx @@ -67,11 +67,29 @@ function DialogInner({ return res }, [state]) - const onChange = (newValues: string[]) => - setState({ - posts: newValues.includes('posts'), - replies: newValues.includes('replies'), + const onChange = (newValues: string[]) => { + setState(oldValues => { + // ensure you can't have replies without posts + if (!oldValues.replies && newValues.includes('replies')) { + return { + posts: true, + replies: true, + } + } + + if (oldValues.posts && !newValues.includes('posts')) { + return { + posts: false, + replies: false, + } + } + + return { + posts: newValues.includes('posts'), + replies: newValues.includes('replies'), + } }) + } const buttonProps: Omit = useMemo(() => { const isDirty =