tweak switch logic
This commit is contained in:
@@ -67,11 +67,29 @@ function DialogInner({
|
|||||||
return res
|
return res
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
const onChange = (newValues: string[]) =>
|
const onChange = (newValues: string[]) => {
|
||||||
setState({
|
setState(oldValues => {
|
||||||
posts: newValues.includes('posts'),
|
// ensure you can't have replies without posts
|
||||||
replies: newValues.includes('replies'),
|
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<ButtonProps, 'children'> = useMemo(() => {
|
const buttonProps: Omit<ButtonProps, 'children'> = useMemo(() => {
|
||||||
const isDirty =
|
const isDirty =
|
||||||
|
|||||||
Reference in New Issue
Block a user