Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33089566
D14611.1768461033.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D14611.1768461033.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
@@ -36,7 +36,6 @@
RoleModificationPayload,
RoleDeletionRequest,
RoleDeletionPayload,
- UpdateThickThreadRequest,
} from '../types/thread-types.js';
import { values } from '../utils/objects.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -114,18 +113,10 @@
};
};
-export type UseChangeThreadSettingsInput = $ReadOnly<
- | {
- ...UpdateThreadRequest,
- +thick: false,
- +threadInfo: ThreadInfo,
- }
- | {
- ...UpdateThickThreadRequest,
- +thick: true,
- +threadInfo: ThreadInfo,
- },
->;
+export type UseChangeThreadSettingsInput = $ReadOnly<{
+ ...UpdateThreadRequest,
+ +threadInfo: ThreadInfo,
+}>;
function useChangeThreadSettings(): (
input: UseChangeThreadSettingsInput,
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,7 +10,6 @@
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 { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -73,12 +72,6 @@
// Use platform-specific `[web/native]SetThreadAvatar` instead.
const baseSetThreadAvatar = React.useCallback(
async (threadID: string, avatarRequest: UpdateUserAvatarRequest) => {
- const updateThreadRequest = {
- threadID,
- changes: {
- avatar: avatarRequest,
- },
- };
const action = changeThreadSettingsActionTypes.started;
if (
avatarRequest.type === 'image' ||
@@ -86,9 +79,13 @@
) {
updateThreadAvatarMediaUploadInProgress(false);
}
- const updateThreadInput = threadTypeIsThick(threadInfo.type)
- ? { thick: true, threadInfo, ...updateThreadRequest }
- : { thick: false, threadInfo, ...updateThreadRequest };
+ const updateThreadInput = {
+ threadInfo,
+ threadID,
+ changes: {
+ avatar: avatarRequest,
+ },
+ };
const promise = changeThreadSettingsCall(updateThreadInput);
void dispatchActionPromise(changeThreadSettingsActionTypes, promise, {
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,7 +69,6 @@
changeThreadSettingsActionTypes,
(async () => {
return await callChangeThreadSettings({
- thick: false,
threadID: threadInfo.id,
threadInfo,
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
@@ -324,15 +324,10 @@
return;
}
- const changeThreadSettingsRequest = {
- threadID: threadInfo.id,
- changes: { newMemberIDs },
- };
-
const changeThreadSettingsInput = {
- thick: false,
threadInfo,
- ...changeThreadSettingsRequest,
+ threadID: threadInfo.id,
+ changes: { newMemberIDs },
};
const addMembersPromise = callChangeThreadSettings(
diff --git a/lib/shared/threads/protocols/dm-thread-protocol.js b/lib/shared/threads/protocols/dm-thread-protocol.js
--- a/lib/shared/threads/protocols/dm-thread-protocol.js
+++ b/lib/shared/threads/protocols/dm-thread-protocol.js
@@ -191,6 +191,11 @@
) => {
const { viewerID, input } = protocolInput;
invariant(viewerID, 'viewerID should be set');
+ invariant(
+ !input.changes.newMemberIDs,
+ "DM protocol doesn't support" +
+ ' adding new members when changing thread settings',
+ );
const changes: { ...DMThreadSettingsChanges } = {};
if (input.changes.name) {
diff --git a/lib/shared/threads/protocols/keyserver-thread-protocol.js b/lib/shared/threads/protocols/keyserver-thread-protocol.js
--- a/lib/shared/threads/protocols/keyserver-thread-protocol.js
+++ b/lib/shared/threads/protocols/keyserver-thread-protocol.js
@@ -178,7 +178,7 @@
protocolInput: ProtocolChangeThreadSettingsInput,
utils: ChangeThreadSettingsUtils,
) => {
- const { thick, threadInfo, ...rest } = protocolInput.input;
+ const { threadInfo, ...rest } = protocolInput.input;
return await utils.keyserverChangeThreadSettings({ ...rest });
},
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -317,32 +317,22 @@
},
};
-type BaseThreadChanges = {
- +type: ThinThreadType,
- +name: string,
- +description: string,
- +color: string,
- +parentThreadID: ?string,
- +avatar: UpdateUserAvatarRequest,
+export type ThreadChanges = {
+ +type?: ThinThreadType,
+ +name?: string,
+ +description?: string,
+ +color?: string,
+ +parentThreadID?: ?string,
+ +avatar?: UpdateUserAvatarRequest,
+ +newMemberIDs?: $ReadOnlyArray<string>,
};
-export type ThreadChanges = Partial<BaseThreadChanges>;
-
-export type ThinThreadChanges = $ReadOnly<
- $Partial<{ ...BaseThreadChanges, +newMemberIDs: $ReadOnlyArray<string> }>,
->;
-
export type UpdateThreadRequest = {
+threadID: string,
- +changes: ThinThreadChanges,
+ +changes: ThreadChanges,
+accountPassword?: empty,
};
-export type UpdateThickThreadRequest = $ReadOnly<{
- ...UpdateThreadRequest,
- +changes: ThreadChanges,
-}>;
-
export type BaseNewThreadRequest = {
+id?: ?string,
+name?: ?string,
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
@@ -78,7 +78,6 @@
const addUsersToThread = React.useCallback(async () => {
try {
const result = await callChangeThreadSettings({
- thick: false,
threadID: threadInfo.id,
changes: { newMemberIDs: userInfoInputIDs },
threadInfo,
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
@@ -10,7 +10,6 @@
type UseChangeThreadSettingsInput,
} from 'lib/actions/thread-actions.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
import { type ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
type DispatchActionPromise,
@@ -98,24 +97,11 @@
async (newColor: string) => {
const threadID = threadInfo.id;
try {
- const changeThreadSettingRequest = {
+ const changeThreadSettingInput = {
+ threadInfo: props.route.params.threadInfo,
threadID,
changes: { color: newColor },
};
-
- const changeThreadSettingInput = threadTypeIsThick(
- props.route.params.threadInfo.type,
- )
- ? {
- thick: true,
- threadInfo: props.route.params.threadInfo,
- ...changeThreadSettingRequest,
- }
- : {
- thick: false,
- threadInfo: props.route.params.threadInfo,
- ...changeThreadSettingRequest,
- };
return await updateThreadSettings(changeThreadSettingInput);
} catch (e) {
Alert.alert(
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
@@ -19,7 +19,6 @@
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 { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
import { type ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
type DispatchActionPromise,
@@ -264,25 +263,12 @@
newDescription: string,
): Promise<ChangeThreadSettingsPayload> {
try {
- const changeThreadSettingsRequest = {
+ const changeThreadSettingsInput = {
+ threadInfo: this.props.threadInfo,
threadID: this.props.threadInfo.id,
changes: { description: newDescription },
};
- const changeThreadSettingsInput = threadTypeIsThick(
- this.props.threadInfo.type,
- )
- ? {
- thick: true,
- threadInfo: this.props.threadInfo,
- ...changeThreadSettingsRequest,
- }
- : {
- thick: false,
- threadInfo: this.props.threadInfo,
- ...changeThreadSettingsRequest,
- };
-
return await this.props.changeThreadSettings(changeThreadSettingsInput);
} catch (e) {
Alert.alert(
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
@@ -17,7 +17,6 @@
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 { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
import type { ChangeThreadSettingsPayload } from 'lib/types/thread-types.js';
import {
useDispatchActionPromise,
@@ -192,25 +191,12 @@
async editName(newName: string): Promise<ChangeThreadSettingsPayload> {
try {
- const changeThreadSetingsRequest = {
+ const changeThreadSettingsInput = {
+ threadInfo: this.props.threadInfo,
threadID: this.props.threadInfo.id,
changes: { name: newName },
};
- const changeThreadSettingsInput = threadTypeIsThick(
- this.props.threadInfo.type,
- )
- ? {
- thick: true,
- threadInfo: this.props.threadInfo,
- ...changeThreadSetingsRequest,
- }
- : {
- thick: false,
- threadInfo: this.props.threadInfo,
- ...changeThreadSetingsRequest,
- };
-
return await this.props.changeThreadSettings(changeThreadSettingsInput);
} catch (e) {
Alert.alert(
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,7 +75,6 @@
void dispatchActionPromise(
changeThreadSettingsActionTypes,
callChangeThreadSettings({
- thick: false,
threadID,
threadInfo,
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,7 +12,6 @@
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';
@@ -38,19 +37,12 @@
const changeThreadSettingsAction = React.useCallback(async () => {
try {
setErrorMessage('');
- const changeThreadSettingsRequest = {
+ const changeThreadSettingsInput = {
+ threadInfo,
threadID: threadInfo.id,
changes: queuedChanges,
};
- const changeThreadSettingsInput = threadTypeIsThick(threadInfo.type)
- ? {
- thick: true,
- threadInfo,
- ...changeThreadSettingsRequest,
- }
- : { thick: false, threadInfo, ...changeThreadSettingsRequest };
-
return await callChangeThreadSettings(changeThreadSettingsInput);
} catch (e) {
setErrorMessage('unknown_error');
@@ -101,7 +93,6 @@
try {
setErrorMessage('');
const response = await callChangeThreadSettings({
- thick: false,
threadID: threadInfo.id,
changes: queuedChanges,
threadInfo,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 15, 7:10 AM (20 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5936657
Default Alt Text
D14611.1768461033.diff (12 KB)
Attached To
Mode
D14611: [lib] Simplify thread settings types
Attached
Detach File
Event Timeline
Log In to Comment