Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2765432
D13287.id44031.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D13287.id44031.diff
View Options
diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js
--- a/lib/actions/thread-actions.js
+++ b/lib/actions/thread-actions.js
@@ -24,10 +24,7 @@
ThreadInfo,
RawThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
-import {
- thickThreadTypes,
- threadTypeIsThick,
-} from '../types/thread-types-enum.js';
+import { thickThreadTypes } from '../types/thread-types-enum.js';
import type {
ChangeThreadSettingsPayload,
LeaveThreadPayload,
@@ -119,9 +116,21 @@
};
};
-function useChangeThreadSettings(
- threadInfo: ?ThreadInfo,
-): (input: UpdateThreadRequest) => Promise<ChangeThreadSettingsPayload> {
+export type UseChangeThreadSettingsInput = $ReadOnly<
+ | {
+ ...UpdateThreadRequest,
+ +thick: false,
+ }
+ | {
+ ...UpdateThreadRequest,
+ +thick: true,
+ +threadInfo: ThreadInfo,
+ },
+>;
+
+function useChangeThreadSettings(): (
+ input: UseChangeThreadSettingsInput,
+) => Promise<ChangeThreadSettingsPayload> {
const processAndSendDMOperation = useProcessAndSendDMOperation();
const viewerID = useSelector(
state => state.currentUserInfo && state.currentUserInfo.id,
@@ -130,9 +139,10 @@
const keyserverCall = useKeyserverCall(changeThreadSettings);
return React.useCallback(
- async (input: UpdateThreadRequest) => {
- if (!threadInfo || !threadTypeIsThick(threadInfo.type)) {
- return await keyserverCall(input);
+ async (input: UseChangeThreadSettingsInput) => {
+ if (!input.thick) {
+ const { thick, ...rest } = input;
+ return await keyserverCall({ ...rest });
}
invariant(viewerID, 'viewerID should be set');
@@ -159,7 +169,7 @@
// To support `image` and `encrypted_image` avatars we first, need stop
// sending multimedia metadata to keyserver.
// ENG-8708
-
+ const { threadInfo } = input;
const op: DMChangeThreadSettingsOperation = {
type: 'change_thread_settings',
threadID: threadInfo.id,
@@ -188,7 +198,7 @@
newMessageInfos: [],
}: ChangeThreadSettingsPayload);
},
- [keyserverCall, processAndSendDMOperation, threadInfo, viewerID],
+ [keyserverCall, processAndSendDMOperation, viewerID],
);
}
diff --git a/lib/components/base-edit-thread-avatar-provider.react.js b/lib/components/base-edit-thread-avatar-provider.react.js
--- a/lib/components/base-edit-thread-avatar-provider.react.js
+++ b/lib/components/base-edit-thread-avatar-provider.react.js
@@ -10,6 +10,7 @@
import { threadInfoSelector } from '../selectors/thread-selectors.js';
import type { UpdateUserAvatarRequest } from '../types/avatar-types.js';
import type { LoadingStatus } from '../types/loading-types.js';
+import { threadTypeIsThick } from '../types/thread-types-enum.js';
import type { UpdateThreadRequest } from '../types/thread-types.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -44,7 +45,7 @@
state => threadInfoSelector(state)[activeThreadID],
);
const dispatchActionPromise = useDispatchActionPromise();
- const changeThreadSettingsCall = useChangeThreadSettings(threadInfo);
+ const changeThreadSettingsCall = useChangeThreadSettings();
const [
threadAvatarMediaUploadInProgress,
@@ -86,13 +87,18 @@
) {
updateThreadAvatarMediaUploadInProgress(false);
}
- const promise = changeThreadSettingsCall(updateThreadRequest);
+ const updateThreadInput = threadTypeIsThick(threadInfo.type)
+ ? { thick: true, threadInfo, ...updateThreadRequest }
+ : { thick: false, ...updateThreadRequest };
+
+ const promise = changeThreadSettingsCall(updateThreadInput);
void dispatchActionPromise(changeThreadSettingsActionTypes, promise, {
customKeyName: `${action}:${threadID}:avatar`,
});
await promise;
},
[
+ threadInfo,
changeThreadSettingsCall,
dispatchActionPromise,
updateThreadAvatarMediaUploadInProgress,
diff --git a/lib/hooks/promote-sidebar.react.js b/lib/hooks/promote-sidebar.react.js
--- a/lib/hooks/promote-sidebar.react.js
+++ b/lib/hooks/promote-sidebar.react.js
@@ -69,6 +69,7 @@
changeThreadSettingsActionTypes,
(async () => {
return await callChangeThreadSettings({
+ thick: false,
threadID: threadInfo.id,
changes: { type: threadTypes.COMMUNITY_OPEN_SUBTHREAD },
});
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -27,7 +27,10 @@
} from '../../types/messages/text.js';
import type { ThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import type { NotifTexts } from '../../types/notif-types.js';
-import { threadTypeIsSidebar } from '../../types/thread-types-enum.js';
+import {
+ threadTypeIsSidebar,
+ threadTypeIsThick,
+} from '../../types/thread-types-enum.js';
import type { RelativeUserInfo } from '../../types/user-types.js';
import { ET } from '../../utils/entity-text.js';
import { useDispatchActionPromise } from '../../utils/redux-promise-utils.js';
@@ -313,10 +316,17 @@
}
const newMemberIDs = mentionedNewMembers.map(({ id }) => id);
- const addMembersPromise = callChangeThreadSettings({
+ const changeThreadSettingsRequest = {
threadID: threadInfo.id,
changes: { newMemberIDs },
- });
+ };
+ const changeThreadSettingsInput = threadTypeIsThick(threadInfo.type)
+ ? { thick: true, threadInfo, ...changeThreadSettingsRequest }
+ : { thick: false, ...changeThreadSettingsRequest };
+
+ const addMembersPromise = callChangeThreadSettings(
+ changeThreadSettingsInput,
+ );
void dispatchActionPromise(
changeThreadSettingsActionTypes,
diff --git a/native/chat/settings/add-users-modal.react.js b/native/chat/settings/add-users-modal.react.js
--- a/native/chat/settings/add-users-modal.react.js
+++ b/native/chat/settings/add-users-modal.react.js
@@ -79,6 +79,7 @@
const addUsersToThread = React.useCallback(async () => {
try {
const result = await callChangeThreadSettings({
+ thick: false,
threadID: threadID,
changes: { newMemberIDs: userInfoInputIDs },
});
diff --git a/native/chat/settings/color-selector-modal.react.js b/native/chat/settings/color-selector-modal.react.js
--- a/native/chat/settings/color-selector-modal.react.js
+++ b/native/chat/settings/color-selector-modal.react.js
@@ -8,11 +8,10 @@
changeThreadSettingsActionTypes,
useChangeThreadSettings,
} from 'lib/actions/thread-actions.js';
+import type { UseChangeThreadSettingsInput } from 'lib/actions/thread-actions.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import {
- type ChangeThreadSettingsPayload,
- type UpdateThreadRequest,
-} from 'lib/types/thread-types.js';
+import { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
+import { type ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
type DispatchActionPromise,
useDispatchActionPromise,
@@ -78,7 +77,7 @@
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+changeThreadSettings: (
- request: UpdateThreadRequest,
+ input: UseChangeThreadSettingsInput,
) => Promise<ChangeThreadSettingsPayload>,
};
function ColorSelectorModal(props: Props): React.Node {
@@ -99,10 +98,21 @@
async (newColor: string) => {
const threadID = threadInfo.id;
try {
- return await updateThreadSettings({
+ const changeThreadSettingRequest = {
threadID,
changes: { color: newColor },
- });
+ };
+
+ const changeThreadSettingInput = threadTypeIsThick(
+ props.route.params.threadInfo.type,
+ )
+ ? {
+ thick: true,
+ threadInfo: props.route.params.threadInfo,
+ ...changeThreadSettingRequest,
+ }
+ : { thick: false, ...changeThreadSettingRequest };
+ return await updateThreadSettings(changeThreadSettingInput);
} catch (e) {
Alert.alert(
unknownErrorAlertDetails.title,
@@ -113,7 +123,12 @@
throw e;
}
},
- [onErrorAcknowledged, threadInfo.id, updateThreadSettings],
+ [
+ onErrorAcknowledged,
+ threadInfo.id,
+ updateThreadSettings,
+ props.route.params.threadInfo,
+ ],
);
const onColorSelected = React.useCallback(
@@ -176,9 +191,7 @@
const windowWidth = useSelector(state => state.dimensions.width);
const dispatchActionPromise = useDispatchActionPromise();
- const callChangeThreadSettings = useChangeThreadSettings(
- props.route.params.threadInfo,
- );
+ const callChangeThreadSettings = useChangeThreadSettings();
return (
<ColorSelectorModal
diff --git a/native/chat/settings/thread-settings-description.react.js b/native/chat/settings/thread-settings-description.react.js
--- a/native/chat/settings/thread-settings-description.react.js
+++ b/native/chat/settings/thread-settings-description.react.js
@@ -13,15 +13,13 @@
changeThreadSettingsActionTypes,
useChangeThreadSettings,
} from 'lib/actions/thread-actions.js';
+import type { UseChangeThreadSettingsInput } from 'lib/actions/thread-actions.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { useThreadHasPermission } from 'lib/shared/thread-utils.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
-import {
- type ChangeThreadSettingsPayload,
- type UpdateThreadRequest,
-} from 'lib/types/thread-types.js';
+import { type ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
type DispatchActionPromise,
useDispatchActionPromise,
@@ -105,7 +103,7 @@
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+changeThreadSettings: (
- update: UpdateThreadRequest,
+ input: UseChangeThreadSettingsInput,
) => Promise<ChangeThreadSettingsPayload>,
+canEditThreadDescription: boolean,
};
@@ -266,6 +264,7 @@
): Promise<ChangeThreadSettingsPayload> {
try {
return await this.props.changeThreadSettings({
+ thick: false,
threadID: this.props.threadInfo.id,
changes: { description: newDescription },
});
@@ -306,7 +305,7 @@
const styles = useStyles(unboundStyles);
const dispatchActionPromise = useDispatchActionPromise();
- const callChangeThreadSettings = useChangeThreadSettings(props.threadInfo);
+ const callChangeThreadSettings = useChangeThreadSettings();
const canEditThreadDescription = useThreadHasPermission(
props.threadInfo,
diff --git a/native/chat/settings/thread-settings-name.react.js b/native/chat/settings/thread-settings-name.react.js
--- a/native/chat/settings/thread-settings-name.react.js
+++ b/native/chat/settings/thread-settings-name.react.js
@@ -13,13 +13,12 @@
changeThreadSettingsActionTypes,
useChangeThreadSettings,
} from 'lib/actions/thread-actions.js';
+import type { UseChangeThreadSettingsInput } from 'lib/actions/thread-actions.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { ResolvedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import type {
- ChangeThreadSettingsPayload,
- UpdateThreadRequest,
-} from 'lib/types/thread-types.js';
+import { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
+import type { ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
useDispatchActionPromise,
type DispatchActionPromise,
@@ -77,7 +76,7 @@
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+changeThreadSettings: (
- update: UpdateThreadRequest,
+ input: UseChangeThreadSettingsInput,
) => Promise<ChangeThreadSettingsPayload>,
};
class ThreadSettingsName extends React.PureComponent<Props> {
@@ -193,10 +192,22 @@
async editName(newName: string): Promise<ChangeThreadSettingsPayload> {
try {
- return await this.props.changeThreadSettings({
+ const changeThreadSetingsRequest = {
threadID: this.props.threadInfo.id,
changes: { name: newName },
- });
+ };
+
+ const changeThreadSettingsInput = threadTypeIsThick(
+ this.props.threadInfo.type,
+ )
+ ? {
+ thick: true,
+ threadInfo: this.props.threadInfo,
+ ...changeThreadSetingsRequest,
+ }
+ : { thick: false, ...changeThreadSetingsRequest };
+
+ return await this.props.changeThreadSettings(changeThreadSettingsInput);
} catch (e) {
Alert.alert(
unknownErrorAlertDetails.title,
@@ -230,7 +241,7 @@
);
const dispatchActionPromise = useDispatchActionPromise();
- const callChangeThreadSettings = useChangeThreadSettings(props.threadInfo);
+ const callChangeThreadSettings = useChangeThreadSettings();
return (
<ThreadSettingsName
diff --git a/web/modals/threads/members/add-members-modal.react.js b/web/modals/threads/members/add-members-modal.react.js
--- a/web/modals/threads/members/add-members-modal.react.js
+++ b/web/modals/threads/members/add-members-modal.react.js
@@ -75,6 +75,7 @@
void dispatchActionPromise(
changeThreadSettingsActionTypes,
callChangeThreadSettings({
+ thick: false,
threadID,
changes: { newMemberIDs },
}),
diff --git a/web/modals/threads/settings/thread-settings-utils.js b/web/modals/threads/settings/thread-settings-utils.js
--- a/web/modals/threads/settings/thread-settings-utils.js
+++ b/web/modals/threads/settings/thread-settings-utils.js
@@ -12,6 +12,7 @@
import { containedThreadInfos } from 'lib/selectors/thread-selectors.js';
import { type SetState } from 'lib/types/hook-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
+import { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
import { type ThreadChanges } from 'lib/types/thread-types.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -32,15 +33,25 @@
params;
const dispatchActionPromise = useDispatchActionPromise();
- const callChangeThreadSettings = useChangeThreadSettings(threadInfo);
+ const callChangeThreadSettings = useChangeThreadSettings();
const changeThreadSettingsAction = React.useCallback(async () => {
try {
setErrorMessage('');
- return await callChangeThreadSettings({
+ const changeThreadSettingsRequest = {
threadID: threadInfo.id,
changes: queuedChanges,
- });
+ };
+
+ const changeThreadSettingsInput = threadTypeIsThick(threadInfo.type)
+ ? {
+ thick: true,
+ threadInfo,
+ ...changeThreadSettingsRequest,
+ }
+ : { thick: false, ...changeThreadSettingsRequest };
+
+ return await callChangeThreadSettings(changeThreadSettingsInput);
} catch (e) {
setErrorMessage('unknown_error');
throw e;
@@ -52,7 +63,7 @@
queuedChanges,
setErrorMessage,
setQueuedChanges,
- threadInfo.id,
+ threadInfo,
]);
const onSubmit = React.useCallback(
@@ -90,6 +101,7 @@
try {
setErrorMessage('');
const response = await callChangeThreadSettings({
+ thick: false,
threadID: threadInfo.id,
changes: queuedChanges,
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 20, 2:36 PM (18 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2150371
Default Alt Text
D13287.id44031.diff (15 KB)
Attached To
Mode
D13287: Update input type of useChangeThreadSettings
Attached
Detach File
Event Timeline
Log In to Comment