diff --git a/lib/types/thread-types-enum.js b/lib/types/thread-types-enum.js index f50206fc06..c1e9cd97ed 100644 --- a/lib/types/thread-types-enum.js +++ b/lib/types/thread-types-enum.js @@ -161,6 +161,11 @@ export const sidebarThreadTypes: $ReadOnlyArray = Object.freeze([ threadTypes.THICK_SIDEBAR, ]); +export const personalThreadTypes: $ReadOnlyArray = Object.freeze([ + threadTypes.PERSONAL, + threadTypes.GENESIS_PERSONAL, +]); + export function threadTypeIsCommunityRoot(threadType: ThreadType): boolean { return communityThreadTypes.includes(threadType); } @@ -174,3 +179,7 @@ export function threadTypeIsAnnouncementThread( export function threadTypeIsSidebar(threadType: ThreadType): boolean { return sidebarThreadTypes.includes(threadType); } + +export function threadTypeIsPersonal(threadType: ThreadType): boolean { + return personalThreadTypes.includes(threadType); +} diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js index 87cf0354a1..05ea16b7b8 100644 --- a/native/chat/settings/thread-settings.react.js +++ b/native/chat/settings/thread-settings.react.js @@ -46,9 +46,9 @@ import type { import type { RelationshipButton } from 'lib/types/relationship-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { - threadTypes, threadTypeIsSidebar, threadTypeIsThick, + threadTypeIsPersonal, } from 'lib/types/thread-types-enum.js'; import type { UserInfos } from 'lib/types/user-types.js'; import { @@ -768,9 +768,7 @@ class ThreadSettings extends React.PureComponent { }); } - const threadIsPersonal = - threadInfo.type === threadTypes.GENESIS_PERSONAL; - if (threadIsPersonal && viewerID) { + if (threadInfo && threadTypeIsPersonal(threadInfo.type) && viewerID) { const otherMemberID = getSingleOtherUser(threadInfo, viewerID); if (otherMemberID) { const otherUserInfo = userInfos[otherMemberID]; diff --git a/web/modals/threads/settings/thread-settings-modal.react.js b/web/modals/threads/settings/thread-settings-modal.react.js index 9acd0e9079..6a5289721b 100644 --- a/web/modals/threads/settings/thread-settings-modal.react.js +++ b/web/modals/threads/settings/thread-settings-modal.react.js @@ -19,7 +19,10 @@ import { import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import type { RelationshipButton } from 'lib/types/relationship-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { threadTypes } from 'lib/types/thread-types-enum.js'; +import { + threadTypeIsPersonal, + threadTypes, +} from 'lib/types/thread-types-enum.js'; import { type ThreadChanges } from 'lib/types/thread-types.js'; import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js'; @@ -91,11 +94,15 @@ const ConnectedThreadSettingsModal: React.ComponentType = const otherUserInfo = otherMemberID ? userInfos[otherMemberID] : null; const availableRelationshipActions = React.useMemo(() => { - if (!otherUserInfo) { + if ( + !otherUserInfo || + !threadInfo?.type || + !threadTypeIsPersonal(threadInfo.type) + ) { return ([]: RelationshipButton[]); } return getAvailableRelationshipButtons(otherUserInfo); - }, [otherUserInfo]); + }, [otherUserInfo, threadInfo?.type]); const canEditThreadName = useThreadHasPermission( threadInfo,