Page MenuHomePhabricator

D3828.id11948.diff
No OneTemporary

D3828.id11948.diff

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<HTMLInputElement>) => {
- 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<HTMLInputElement>) => {
const target = event.currentTarget;
@@ -253,11 +237,10 @@
} else if (currentTabType === 'privacy') {
mainContent = (
<ThreadSettingsPrivacyTab
- possiblyChangedThreadType={
- queuedChanges['type'] ?? threadInfo['type']
- }
- onChangeThreadType={onChangeThreadType}
inputDisabled={inputDisabled}
+ threadInfo={threadInfo}
+ queuedChanges={queuedChanges}
+ setQueuedChanges={setQueuedChanges}
/>
);
} 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<HTMLInputElement>) => void,
+inputDisabled: boolean,
+ +threadInfo: ThreadInfo,
+ +queuedChanges: ThreadChanges,
+ +setQueuedChanges: SetState<ThreadChanges>,
};
function ThreadSettingsPrivacyTab(
props: ThreadSettingsPrivacyTabProps,
): React.Node {
- const {
- possiblyChangedThreadType,
- onChangeThreadType,
- inputDisabled,
- } = props;
+ const { inputDisabled, threadInfo, queuedChanges, setQueuedChanges } = props;
+
+ const onChangeThreadType = React.useCallback(
+ (event: SyntheticEvent<HTMLInputElement>) => {
+ const uiValue = assertThreadType(parseInt(event.currentTarget.value, 10));
+ setQueuedChanges(
+ Object.freeze({
+ ...queuedChanges,
+ type: uiValue !== threadInfo.type ? uiValue : undefined,
+ }),
+ );
+ },
+ [queuedChanges, setQueuedChanges, threadInfo.type],
+ );
+
return (
<div className={css.edit_thread_privacy_container}>
<div className={css['modal-radio-selector']}>
@@ -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}
/>

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 7:39 PM (20 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2444757
Default Alt Text
D3828.id11948.diff (4 KB)

Event Timeline