diff --git a/web/modals/threads/thread-settings-modal.react.js b/web/modals/threads/thread-settings-modal.react.js --- a/web/modals/threads/thread-settings-modal.react.js +++ b/web/modals/threads/thread-settings-modal.react.js @@ -16,7 +16,6 @@ import { type ThreadInfo, threadTypes, - assertThreadType, threadPermissions, type ThreadChanges, } from 'lib/types/thread-types'; @@ -109,21 +108,6 @@ [queuedChanges], ); - const onChangeThreadType = React.useCallback( - (event: SyntheticEvent) => { - const uiValue = assertThreadType( - parseInt(event.currentTarget.value, 10), - ); - setQueuedChanges( - Object.freeze({ - ...queuedChanges, - type: uiValue !== threadInfo?.type ? uiValue : undefined, - }), - ); - }, - [queuedChanges, threadInfo?.type], - ); - const onChangeAccountPassword = React.useCallback( (event: SyntheticEvent) => { const target = event.currentTarget; @@ -253,11 +237,10 @@ } else if (currentTabType === 'privacy') { mainContent = ( ); } else if (currentTabType === 'delete') { diff --git a/web/modals/threads/thread-settings-privacy-tab.react.js b/web/modals/threads/thread-settings-privacy-tab.react.js --- a/web/modals/threads/thread-settings-privacy-tab.react.js +++ b/web/modals/threads/thread-settings-privacy-tab.react.js @@ -2,25 +2,43 @@ import * as React from 'react'; -import { threadTypeDescriptions } from 'lib/shared/thread-utils.js'; -import { threadTypes } from 'lib/types/thread-types.js'; +import { threadTypeDescriptions } from 'lib/shared/thread-utils'; +import { type SetState } from 'lib/types/hook-types'; +import { + type ThreadInfo, + type ThreadChanges, + assertThreadType, + threadTypes, +} from 'lib/types/thread-types'; import css from './thread-settings-privacy-tab.css'; + const { COMMUNITY_OPEN_SUBTHREAD, COMMUNITY_SECRET_SUBTHREAD } = threadTypes; type ThreadSettingsPrivacyTabProps = { - +possiblyChangedThreadType: number, - +onChangeThreadType: (event: SyntheticEvent) => void, +inputDisabled: boolean, + +threadInfo: ThreadInfo, + +queuedChanges: ThreadChanges, + +setQueuedChanges: SetState, }; function ThreadSettingsPrivacyTab( props: ThreadSettingsPrivacyTabProps, ): React.Node { - const { - possiblyChangedThreadType, - onChangeThreadType, - inputDisabled, - } = props; + const { inputDisabled, threadInfo, queuedChanges, setQueuedChanges } = props; + + const onChangeThreadType = React.useCallback( + (event: SyntheticEvent) => { + const uiValue = assertThreadType(parseInt(event.currentTarget.value, 10)); + setQueuedChanges( + Object.freeze({ + ...queuedChanges, + type: uiValue !== threadInfo.type ? uiValue : undefined, + }), + ); + }, + [queuedChanges, setQueuedChanges, threadInfo.type], + ); + return (
@@ -32,7 +50,10 @@ name="edit-thread-type" id="edit-thread-open" value={COMMUNITY_OPEN_SUBTHREAD} - checked={possiblyChangedThreadType === COMMUNITY_OPEN_SUBTHREAD} + checked={ + (queuedChanges.type ?? threadInfo.type) === + COMMUNITY_OPEN_SUBTHREAD + } onChange={onChangeThreadType} disabled={inputDisabled} /> @@ -51,7 +72,10 @@ name="edit-thread-type" id="edit-thread-closed" value={COMMUNITY_SECRET_SUBTHREAD} - checked={possiblyChangedThreadType === COMMUNITY_SECRET_SUBTHREAD} + checked={ + (queuedChanges.type ?? threadInfo.type) === + COMMUNITY_SECRET_SUBTHREAD + } onChange={onChangeThreadType} disabled={inputDisabled} />