Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32209944
D15236.1765128909.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D15236.1765128909.diff
View Options
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
@@ -924,6 +924,12 @@
shouldConvertIDs: false,
dataIsBackedUp: true,
+ supportedThreadSettings: {
+ avatar: true,
+ name: true,
+ description: true,
+ color: true,
+ },
});
function pendingThreadType(numberOfOtherMembers: number) {
diff --git a/lib/shared/threads/protocols/farcaster-thread-protocol.js b/lib/shared/threads/protocols/farcaster-thread-protocol.js
--- a/lib/shared/threads/protocols/farcaster-thread-protocol.js
+++ b/lib/shared/threads/protocols/farcaster-thread-protocol.js
@@ -272,6 +272,14 @@
membershipMessageNotifAction: messageNotifyTypes.NONE,
shouldConvertIDs: false,
dataIsBackedUp: true,
+
+ supportedThreadSettings: {
+ avatar: true,
+ name: true,
+ description: true,
+ // Farcaster threads do not support color changes
+ color: false,
+ },
};
export { farcasterThreadProtocol };
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
@@ -680,6 +680,13 @@
shouldConvertIDs: true,
dataIsBackedUp: false,
+
+ supportedThreadSettings: {
+ avatar: true,
+ name: true,
+ description: true,
+ color: true,
+ },
});
function pendingThreadType(numberOfOtherMembers: number) {
diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js
--- a/lib/shared/threads/thread-spec.js
+++ b/lib/shared/threads/thread-spec.js
@@ -423,6 +423,12 @@
// In practice, this means that this data storage is in tables
// that are included in the backup.
+dataIsBackedUp: boolean,
+ +supportedThreadSettings: {
+ +avatar: boolean,
+ +name: boolean,
+ +description: boolean,
+ +color: boolean,
+ },
};
export type ThreadSpec<
diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js
--- a/native/chat/settings/thread-settings.react.js
+++ b/native/chat/settings/thread-settings.react.js
@@ -381,7 +381,13 @@
canEditThreadDescription: boolean,
canEditThreadColor: boolean,
) => {
- const canChangeAvatar = canEditThreadAvatar && canStartEditing;
+ const { supportedThreadSettings } =
+ threadSpecs[threadInfo.type].protocol();
+
+ const canChangeAvatar =
+ canEditThreadAvatar &&
+ canStartEditing &&
+ supportedThreadSettings.avatar;
const canChangeName = canEditThreadName && canStartEditing;
const canChangeDescription =
canEditThreadDescription && canStartEditing;
@@ -412,33 +418,41 @@
title: 'Basics',
categoryType: 'full',
});
- listData.push({
- itemType: 'name',
- key: 'name',
- threadInfo,
- nameEditValue,
- canChangeSettings: canChangeName,
- });
- listData.push({
- itemType: 'color',
- key: 'color',
- threadInfo,
- colorEditValue,
- canChangeSettings: canChangeColor,
- navigate,
- threadSettingsRouteKey: routeKey,
- });
+ if (supportedThreadSettings.name) {
+ listData.push({
+ itemType: 'name',
+ key: 'name',
+ threadInfo,
+ nameEditValue,
+ canChangeSettings: canChangeName,
+ });
+ }
+ if (supportedThreadSettings.color) {
+ listData.push({
+ itemType: 'color',
+ key: 'color',
+ threadInfo,
+ colorEditValue,
+ canChangeSettings: canChangeColor,
+ navigate,
+ threadSettingsRouteKey: routeKey,
+ });
+ }
listData.push({
itemType: 'footer',
key: 'basicsFooter',
categoryType: 'full',
});
- if (
+ const shouldShowThreadDescription =
(descriptionEditValue !== null &&
descriptionEditValue !== undefined) ||
threadInfo.description ||
- canEditThreadDescription
+ canEditThreadDescription;
+
+ if (
+ shouldShowThreadDescription &&
+ supportedThreadSettings.description
) {
listData.push({
itemType: 'description',
diff --git a/web/avatars/edit-thread-avatar.react.js b/web/avatars/edit-thread-avatar.react.js
--- a/web/avatars/edit-thread-avatar.react.js
+++ b/web/avatars/edit-thread-avatar.react.js
@@ -5,6 +5,7 @@
import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js';
import { useThreadHasPermission } from 'lib/shared/thread-utils.js';
+import { threadSpecs } from 'lib/shared/threads/thread-specs.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
@@ -27,9 +28,15 @@
threadInfo,
threadPermissions.EDIT_THREAD_AVATAR,
);
+ const threadSupportAvatarEdit =
+ threadSpecs[threadInfo.type].protocol().supportedThreadSettings.avatar;
let editThreadAvatarMenu;
- if (canEditThreadAvatar && !threadAvatarSaveInProgress) {
+ if (
+ canEditThreadAvatar &&
+ !threadAvatarSaveInProgress &&
+ threadSupportAvatarEdit
+ ) {
editThreadAvatarMenu = <EditThreadAvatarMenu threadInfo={threadInfo} />;
}
diff --git a/web/modals/threads/settings/thread-settings-general-tab.react.js b/web/modals/threads/settings/thread-settings-general-tab.react.js
--- a/web/modals/threads/settings/thread-settings-general-tab.react.js
+++ b/web/modals/threads/settings/thread-settings-general-tab.react.js
@@ -4,6 +4,7 @@
import tinycolor from 'tinycolor2';
import { useThreadHasPermission } from 'lib/shared/thread-utils.js';
+import { threadSpecs } from 'lib/shared/threads/thread-specs.js';
import { type SetState } from 'lib/types/hook-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
@@ -87,12 +88,12 @@
const threadNameInputDisabled = !canEditThreadName;
- return (
- <div className={css.container}>
- <div>
- <div className={css.editAvatarContainer}>
- <EditThreadAvatar threadInfo={threadInfo} />
- </div>
+ const nameSection = React.useMemo(() => {
+ if (!threadSpecs[threadInfo.type].protocol().supportedThreadSettings.name) {
+ return null;
+ }
+ return (
+ <>
<div className={css.form_title}>Chat name</div>
<div className={css.form_content}>
<Input
@@ -107,7 +108,26 @@
ref={nameInputRef}
/>
</div>
- </div>
+ </>
+ );
+ }, [
+ onChangeName,
+ queuedChanges.name,
+ threadInfo.name,
+ threadInfo.type,
+ threadNameInputDisabled,
+ threadNamePlaceholder,
+ threadSettingsOperationInProgress,
+ ]);
+
+ const descriptionSection = React.useMemo(() => {
+ if (
+ !threadSpecs[threadInfo.type].protocol().supportedThreadSettings
+ .description
+ ) {
+ return null;
+ }
+ return (
<div>
<div className={css.form_title}>Description</div>
<div className={css.form_content}>
@@ -120,6 +140,22 @@
/>
</div>
</div>
+ );
+ }, [
+ onChangeDescription,
+ queuedChanges.description,
+ threadInfo.description,
+ threadInfo.type,
+ threadSettingsOperationInProgress,
+ ]);
+
+ const colorSection = React.useMemo(() => {
+ if (
+ !threadSpecs[threadInfo.type].protocol().supportedThreadSettings.color
+ ) {
+ return null;
+ }
+ return (
<div>
<div className={css.form_title}>Color</div>
<div className={css.colorSelectorContainer}>
@@ -129,6 +165,19 @@
/>
</div>
</div>
+ );
+ }, [onChangeColor, queuedChanges.color, threadInfo.color, threadInfo.type]);
+
+ return (
+ <div className={css.container}>
+ <div>
+ <div className={css.editAvatarContainer}>
+ <EditThreadAvatar threadInfo={threadInfo} />
+ </div>
+ {nameSection}
+ </div>
+ {descriptionSection}
+ {colorSection}
</div>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 5:35 PM (18 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5845208
Default Alt Text
D15236.1765128909.diff (8 KB)
Attached To
Mode
D15236: [lib][web][native] add `canChangeSettings` to `ThreadProtocol` and based on that render UI
Attached
Detach File
Event Timeline
Log In to Comment