Skip to content

Commit

Permalink
[web] Update misc parts of web to support MinimallyEncodedThreadInfo
Browse files Browse the repository at this point in the history
Summary:
Went through and made changes throughout `web` to support `MinimallyEncodedThreadInfo` where changes required were limited to updating signature.

Next diffs will involve changes that need to be made to `native`, `message-spec`s, Redux, `sendPushNotif`, `useResolvedThreadInfo`, etc.

Test Plan: Trusting `flow`

Reviewers: ashoat, ginsu, tomek, rohan

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D9894
  • Loading branch information
atulsmadhugiri committed Nov 16, 2023
1 parent e24fa20 commit 8739b85
Show file tree
Hide file tree
Showing 31 changed files with 98 additions and 32 deletions.
5 changes: 4 additions & 1 deletion lib/shared/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
markdownUserMentionRegex,
decodeChatMentionText,
} from './mention-utils.js';
import type { MinimallyEncodedRelativeMemberInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import type {
RelativeMemberInfo,
ResolvedThreadInfo,
Expand Down Expand Up @@ -198,7 +199,9 @@ function parseList(
}

function createMemberMapForUserMentions(
members: $ReadOnlyArray<RelativeMemberInfo>,
members: $ReadOnlyArray<
RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo,
>,
): $ReadOnlyMap<string, string> {
const membersMap = new Map<string, string>();
members.forEach(member => {
Expand Down
10 changes: 9 additions & 1 deletion web/avatars/edit-thread-avatar-menu.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import * as React from 'react';
import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import type {
MinimallyEncodedRawThreadInfo,
MinimallyEncodedThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js';

import { useUploadAvatarMedia } from './avatar-hooks.react.js';
Expand All @@ -22,7 +26,11 @@ const editIcon = (
);

type Props = {
+threadInfo: RawThreadInfo | ThreadInfo,
+threadInfo:
| RawThreadInfo
| ThreadInfo
| MinimallyEncodedThreadInfo
| MinimallyEncodedRawThreadInfo,
};
function EditThreadAvatarMenu(props: Props): React.Node {
const { threadInfo } = props;
Expand Down
10 changes: 9 additions & 1 deletion web/avatars/edit-thread-avatar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import * as React from 'react';

import { EditThreadAvatarContext } from 'lib/components/base-edit-thread-avatar-provider.react.js';
import { threadHasPermission } from 'lib/shared/thread-utils.js';
import type {
MinimallyEncodedRawThreadInfo,
MinimallyEncodedThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js';

Expand All @@ -13,7 +17,11 @@ import css from './edit-thread-avatar.css';
import ThreadAvatar from './thread-avatar.react.js';

type Props = {
+threadInfo: RawThreadInfo | ThreadInfo,
+threadInfo:
| RawThreadInfo
| ThreadInfo
| MinimallyEncodedRawThreadInfo
| MinimallyEncodedThreadInfo,
+disabled?: boolean,
};
function EditThreadAvatar(props: Props): React.Node {
Expand Down
10 changes: 9 additions & 1 deletion web/avatars/thread-avatar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import {
} from 'lib/shared/avatar-utils.js';
import { getSingleOtherUser } from 'lib/shared/thread-utils.js';
import type { AvatarSize } from 'lib/types/avatar-types.js';
import type {
MinimallyEncodedRawThreadInfo,
MinimallyEncodedThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
import { type RawThreadInfo, type ThreadInfo } from 'lib/types/thread-types.js';

import Avatar from './avatar.react.js';
import { useSelector } from '../redux/redux-utils.js';

type Props = {
+threadInfo: RawThreadInfo | ThreadInfo,
+threadInfo:
| RawThreadInfo
| ThreadInfo
| MinimallyEncodedRawThreadInfo
| MinimallyEncodedThreadInfo,
+size: AvatarSize,
+showSpinner?: boolean,
};
Expand Down
10 changes: 9 additions & 1 deletion web/avatars/thread-emoji-avatar-selection-modal.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ import type {
ClientAvatar,
ClientEmojiAvatar,
} from 'lib/types/avatar-types.js';
import type {
MinimallyEncodedRawThreadInfo,
MinimallyEncodedThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { RawThreadInfo, ThreadInfo } from 'lib/types/thread-types.js';

import EmojiAvatarSelectionModal from './emoji-avatar-selection-modal.react.js';

type Props = {
+threadInfo: ThreadInfo | RawThreadInfo,
+threadInfo:
| ThreadInfo
| RawThreadInfo
| MinimallyEncodedThreadInfo
| MinimallyEncodedRawThreadInfo,
};

function ThreadEmojiAvatarSelectionModal(props: Props): React.Node {
Expand Down
3 changes: 2 additions & 1 deletion web/calendar/day.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { onScreenThreadInfos as onScreenThreadInfosSelector } from 'lib/selectors/thread-selectors.js';
import { entryKey } from 'lib/shared/entry-utils.js';
import type { EntryInfo } from 'lib/types/entry-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';
import { dateString, dateFromString } from 'lib/utils/date-utils.js';
Expand All @@ -38,7 +39,7 @@ type BaseProps = {
};
type Props = {
...BaseProps,
+onScreenThreadInfos: $ReadOnlyArray<ThreadInfo>,
+onScreenThreadInfos: $ReadOnlyArray<ThreadInfo | MinimallyEncodedThreadInfo>,
+viewerID: ?string,
+loggedIn: boolean,
+nextLocalID: number,
Expand Down
3 changes: 2 additions & 1 deletion web/chat/chat-thread-list-item-menu.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import * as React from 'react';

import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import useToggleUnreadStatus from 'lib/hooks/toggle-unread-status.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import css from './chat-thread-list-item-menu.css';
import Button from '../components/button.react.js';
import { useThreadIsActive } from '../selectors/thread-selectors.js';

type Props = {
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+mostRecentNonLocalMessage: ?string,
+renderStyle?: 'chat' | 'thread',
};
Expand Down
3 changes: 2 additions & 1 deletion web/chat/chat-thread-list-see-more-sidebars.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import * as React from 'react';
import { IoIosMore } from 'react-icons/io/index.js';

import { useModalContext } from 'lib/components/modal-provider.react.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import css from './chat-thread-list.css';
import SidebarsModal from '../modals/threads/sidebars/sidebars-modal.react.js';

type Props = {
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+unread: boolean,
};
function ChatThreadListSeeMoreSidebars(props: Props): React.Node {
Expand Down
3 changes: 2 additions & 1 deletion web/chat/inline-engagement.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js';
import type { ReactionInfo } from 'lib/selectors/chat-selectors.js';
import { getInlineEngagementSidebarText } from 'lib/shared/inline-engagement-utils.js';
import type { MessageInfo } from 'lib/types/message-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import css from './inline-engagement.css';
Expand All @@ -16,7 +17,7 @@ import { useOnClickThread } from '../selectors/thread-selectors.js';

type Props = {
+messageInfo: MessageInfo,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+sidebarThreadInfo: ?ThreadInfo,
+reactions: ReactionInfo,
+positioning: 'left' | 'center' | 'right',
Expand Down
3 changes: 2 additions & 1 deletion web/chat/message-tooltip.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as React from 'react';

import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
import { useNextLocalID } from 'lib/shared/message-utils.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import {
Expand All @@ -32,7 +33,7 @@ type MessageTooltipProps = {
+tooltipPositionStyle: TooltipPositionStyle,
+tooltipSize: TooltipSize,
+item: ChatMessageInfoItem,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
};
function MessageTooltip(props: MessageTooltipProps): React.Node {
const {
Expand Down
3 changes: 2 additions & 1 deletion web/chat/relationship-prompt/relationship-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import {
import * as React from 'react';

import { useRelationshipPrompt } from 'lib/hooks/relationship-prompt.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from 'lib/types/relationship-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import RelationshipPromptButtonContainer from './relationship-prompt-button-container.js';
import RelationshipPromptButton from './relationship-prompt-button.js';
import { buttonThemes } from '../../components/button.react.js';

type Props = { +threadInfo: ThreadInfo };
type Props = { +threadInfo: ThreadInfo | MinimallyEncodedThreadInfo };

function RelationshipPrompt(props: Props) {
const { threadInfo } = props;
Expand Down
3 changes: 2 additions & 1 deletion web/chat/robotext-message.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux';

import { type RobotextChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
import { type ThreadInfo } from 'lib/types/thread-types.js';
import {
Expand Down Expand Up @@ -104,7 +105,7 @@ type BaseInnerThreadEntityProps = {
};
type InnerThreadEntityProps = {
...BaseInnerThreadEntityProps,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+dispatch: Dispatch,
};
class InnerThreadEntity extends React.PureComponent<InnerThreadEntityProps> {
Expand Down
3 changes: 2 additions & 1 deletion web/invite-links/manage/edit-link-modal.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
inviteLinkErrorMessages,
} from 'lib/shared/invite-links.js';
import type { InviteLink } from 'lib/types/link-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import css from './manage-invite-links-modal.css';
Expand All @@ -22,7 +23,7 @@ type Props = {
+inviteLink: ?InviteLink,
+enterViewMode: () => mixed,
+enterDisableMode: () => mixed,
+community: ThreadInfo,
+community: ThreadInfo | MinimallyEncodedThreadInfo,
};

const disableButtonColor = {
Expand Down
10 changes: 8 additions & 2 deletions web/markdown/rules.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import * as SimpleMarkdown from 'simple-markdown';

import * as SharedMarkdown from 'lib/shared/markdown.js';
import { chatMentionRegex } from 'lib/shared/mention-utils.js';
import type {
MinimallyEncodedRelativeMemberInfo,
MinimallyEncodedThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type {
RelativeMemberInfo,
ThreadInfo,
Expand Down Expand Up @@ -165,7 +169,7 @@ const markdownRules: boolean => MarkdownRules = _memoize(useDarkStyle => {
});

function useTextMessageRulesFunc(
threadInfo: ThreadInfo,
threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
chatMentionCandidates: ChatMentionCandidates,
): boolean => MarkdownRules {
const { members } = threadInfo;
Expand All @@ -179,7 +183,9 @@ function useTextMessageRulesFunc(
}

function textMessageRules(
members: $ReadOnlyArray<RelativeMemberInfo>,
members: $ReadOnlyArray<
RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo,
>,
chatMentionCandidates: ChatMentionCandidates,
useDarkStyle: boolean,
): MarkdownRules {
Expand Down
3 changes: 2 additions & 1 deletion web/modals/search/message-search-utils.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import {
} from 'lib/shared/message-utils.js';
import { filterChatMessageInfosForSearch } from 'lib/shared/search-utils.js';
import type { RawMessageInfo } from 'lib/types/message-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import { useSelector } from '../../redux/redux-utils.js';

function useParseSearchResults(
threadInfo: ThreadInfo,
threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
searchResults: $ReadOnlyArray<RawMessageInfo>,
): $ReadOnlyArray<ChatMessageInfoItem> {
const userInfos = useSelector(state => state.userStore.userInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
encryptedVideoThumbnailBlobURI,
} from 'lib/media/media-utils.js';
import type { Media } from 'lib/types/media-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';

import GalleryItem from './thread-settings-media-gallery-item.react.js';
Expand All @@ -21,7 +22,7 @@ type MediaGalleryTab = 'All' | 'Images' | 'Videos';

type ThreadSettingsMediaGalleryModalProps = {
+onClose: () => void,
+parentThreadInfo: ThreadInfo,
+parentThreadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+limit: number,
+activeTab: MediaGalleryTab,
};
Expand Down
3 changes: 2 additions & 1 deletion web/modals/threads/members/change-member-role-modal.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import { otherUsersButNoOtherAdmins } from 'lib/selectors/thread-selectors.js';
import { roleIsAdminRole } from 'lib/shared/thread-utils.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { RelativeMemberInfo, ThreadInfo } from 'lib/types/thread-types';
import { useDispatchActionPromise } from 'lib/utils/action-utils.js';
import { values } from 'lib/utils/objects.js';
Expand All @@ -25,7 +26,7 @@ import UnsavedChangesModal from '../../unsaved-changes-modal.react.js';

type ChangeMemberRoleModalProps = {
+memberInfo: RelativeMemberInfo,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
};

function ChangeMemberRoleModal(props: ChangeMemberRoleModalProps): React.Node {
Expand Down
3 changes: 2 additions & 1 deletion web/modals/threads/members/member.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'lib/shared/thread-utils.js';
import { stringForUser } from 'lib/shared/user-utils.js';
import type { SetState } from 'lib/types/hook-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import {
type RelativeMemberInfo,
type ThreadInfo,
Expand All @@ -31,7 +32,7 @@ const commIconComponent = <CommIcon size={18} icon="user-edit" />;

type Props = {
+memberInfo: RelativeMemberInfo,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+setOpenMenu: SetState<?string>,
};

Expand Down
3 changes: 2 additions & 1 deletion web/modals/threads/members/members-list.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as React from 'react';

import { useENSNames } from 'lib/hooks/ens-cache.js';
import { stringForUser } from 'lib/shared/user-utils.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import {
type ThreadInfo,
type RelativeMemberInfo,
Expand All @@ -16,7 +17,7 @@ import ThreadMember from './member.react.js';
import css from './members-modal.css';

type Props = {
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+threadMembers: $ReadOnlyArray<RelativeMemberInfo>,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import * as React from 'react';

import { useModalContext } from 'lib/components/modal-provider.react.js';
import { getThreadsToDeleteText } from 'lib/shared/thread-utils.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo } from 'lib/types/thread-types';

import css from './thread-settings-delete-confirmation-modal.css';
import Button from '../../../components/button.react.js';
import Modal from '../../modal.react.js';

type BaseProps = {
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+onConfirmation: () => mixed,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useModalContext } from 'lib/components/modal-provider.react.js';
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js';
import { containedThreadInfos } from 'lib/selectors/thread-selectors.js';
import { type SetState } from 'lib/types/hook-types.js';
import type { MinimallyEncodedThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { type ThreadInfo } from 'lib/types/thread-types.js';
import { useDispatchActionPromise } from 'lib/utils/action-utils.js';

Expand All @@ -21,7 +22,7 @@ import { useSelector } from '../../../redux/redux-utils.js';

type ThreadSettingsDeleteTabProps = {
+threadSettingsOperationInProgress: boolean,
+threadInfo: ThreadInfo,
+threadInfo: ThreadInfo | MinimallyEncodedThreadInfo,
+setErrorMessage: SetState<?string>,
+errorMessage?: ?string,
};
Expand Down
Loading

0 comments on commit 8739b85

Please sign in to comment.