diff --git a/web/modals/threads/settings/thread-settings-privacy-tab.css b/web/modals/threads/settings/thread-settings-privacy-tab.css index a5201899a..cde0b13a3 100644 --- a/web/modals/threads/settings/thread-settings-privacy-tab.css +++ b/web/modals/threads/settings/thread-settings-privacy-tab.css @@ -1,15 +1,13 @@ div.form_title { padding-top: 6px; font-size: var(--s-font-14); font-weight: 600; } -span.form_enum_description { - display: flex; - font-size: var(--xs-font-12); - color: gray; +div.enum_container { + padding: 12px 0; } .save_button { width: 100%; } diff --git a/web/modals/threads/settings/thread-settings-privacy-tab.react.js b/web/modals/threads/settings/thread-settings-privacy-tab.react.js index 78fc09b05..7ce91b82d 100644 --- a/web/modals/threads/settings/thread-settings-privacy-tab.react.js +++ b/web/modals/threads/settings/thread-settings-privacy-tab.react.js @@ -1,160 +1,174 @@ // @flow import * as React from 'react'; import { changeThreadSettings, changeThreadSettingsActionTypes, } from 'lib/actions/thread-actions'; 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 { useDispatchActionPromise, useServerCall, } from 'lib/utils/action-utils'; import Button from '../../../components/button.react'; +import EnumSettingsOption from '../../../components/enum-settings-option.react'; +import SWMansionIcon from '../../../SWMansionIcon.react'; import { useModalContext } from '../../modal-provider.react'; import css from './thread-settings-privacy-tab.css'; const { COMMUNITY_OPEN_SUBTHREAD, COMMUNITY_SECRET_SUBTHREAD } = threadTypes; +const openStatements = [ + { + statement: threadTypeDescriptions[COMMUNITY_OPEN_SUBTHREAD], + isStatementValid: true, + }, +]; + +const secretStatements = [ + { + statement: threadTypeDescriptions[COMMUNITY_SECRET_SUBTHREAD], + isStatementValid: true, + }, +]; + type ThreadSettingsPrivacyTabProps = { +inputDisabled: boolean, +threadInfo: ThreadInfo, +queuedChanges: ThreadChanges, +setQueuedChanges: SetState, +setErrorMessage: SetState, }; function ThreadSettingsPrivacyTab( props: ThreadSettingsPrivacyTabProps, ): React.Node { const { inputDisabled, threadInfo, queuedChanges, setQueuedChanges, setErrorMessage, } = props; const modalContext = useModalContext(); const dispatchActionPromise = useDispatchActionPromise(); const callChangeThreadSettings = useServerCall(changeThreadSettings); const changeQueued: boolean = React.useMemo( () => Object.values(queuedChanges).some(v => v !== null && v !== undefined), [queuedChanges], ); - const onChangeThreadType = React.useCallback( - (event: SyntheticEvent) => { - const uiValue = assertThreadType(parseInt(event.currentTarget.value, 10)); - setQueuedChanges(prevQueuedChanges => - Object.freeze({ - ...prevQueuedChanges, - type: uiValue !== threadInfo.type ? uiValue : undefined, - }), - ); - }, - [setQueuedChanges, threadInfo.type], - ); - const changeThreadSettingsAction = React.useCallback(async () => { try { const response = await callChangeThreadSettings({ threadID: threadInfo.id, changes: queuedChanges, }); modalContext.popModal(); return response; } catch (e) { setErrorMessage('unknown_error'); setQueuedChanges(Object.freeze({})); throw e; } }, [ callChangeThreadSettings, modalContext, queuedChanges, setErrorMessage, setQueuedChanges, threadInfo.id, ]); const onSubmit = React.useCallback( (event: SyntheticEvent) => { event.preventDefault(); dispatchActionPromise( changeThreadSettingsActionTypes, changeThreadSettingsAction(), ); }, [changeThreadSettingsAction, dispatchActionPromise], ); + const onOpenSelected = React.useCallback(() => { + setQueuedChanges(prevQueuedChanges => + Object.freeze({ + ...prevQueuedChanges, + type: + COMMUNITY_OPEN_SUBTHREAD !== threadInfo.type + ? COMMUNITY_OPEN_SUBTHREAD + : undefined, + }), + ); + }, [setQueuedChanges, threadInfo.type]); + + const onSecretSelected = React.useCallback(() => { + setQueuedChanges(prevQueuedChanges => + Object.freeze({ + ...prevQueuedChanges, + type: + COMMUNITY_SECRET_SUBTHREAD !== threadInfo.type + ? COMMUNITY_SECRET_SUBTHREAD + : undefined, + }), + ); + }, [setQueuedChanges, threadInfo.type]); + + const globeIcon = React.useMemo( + () => , + [], + ); + + const lockIcon = React.useMemo( + () => , + [], + ); + return (
Thread type
-
- + + -
- -
-
- -
- -
-
); } export default ThreadSettingsPrivacyTab;