From 85f6ebac3f47f93b81fb80b87cc8a783b89b24c7 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Tue, 25 Jul 2023 21:19:10 +1300 Subject: [PATCH 1/3] show user space intro --- .../CommonMemberComponent.tsx | 4 ++ src/pages/OldCommon/store/api.tsx | 38 ++++++++++++++++--- .../ChatComponent/ChatComponent.tsx | 4 ++ .../components/ChatContent/ChatContent.tsx | 4 ++ .../components/FeedTab/FeedTab.tsx | 2 + .../components/MembersTab/MembersTab.tsx | 2 +- .../MembersTab/components/Members/Members.tsx | 11 +++++- .../components/MembersList/MembersList.tsx | 9 ++++- .../DiscussionFeedCard/DiscussionFeedCard.tsx | 4 ++ .../FeedCardHeader/FeedCardHeader.tsx | 4 ++ .../common/components/FeedItem/FeedItem.tsx | 4 ++ .../common/components/FeedItems/FeedItems.tsx | 1 + .../components/FeedLayout/FeedLayout.tsx | 2 + .../components/MobileChat/MobileChat.tsx | 10 ++++- .../Chat/ChatMessage/ChatMessage.tsx | 4 ++ .../components/UserMention/UserMention.tsx | 13 ++++++- .../UserInfoPopup/UserInfoPopup.tsx | 5 ++- src/shared/models/Common.tsx | 2 +- 18 files changed, 108 insertions(+), 15 deletions(-) diff --git a/src/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent.tsx b/src/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent.tsx index 597ba42c30..4f9a7c2e70 100644 --- a/src/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent.tsx +++ b/src/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent.tsx @@ -9,6 +9,7 @@ import { Circle, CirclesPermissions, CommonMemberWithUserInfo, + DirectParent, } from "@/shared/models"; import { CommonMember as CommonMemberModel } from "@/shared/models"; import { ContextMenuRef } from "@/shared/ui-kit"; @@ -29,6 +30,7 @@ interface CommonMemberProps { commonMember?: (CommonMemberModel & CirclesPermissions) | null; governanceCircles: Circle[]; isProject: boolean; + directParent?: DirectParent | null; } const CommonMember: FC = ({ @@ -39,6 +41,7 @@ const CommonMember: FC = ({ commonMember, governanceCircles, isProject, + directParent, }) => { const { isShowing, onClose, onOpen } = useModal(false); const contextMenuRef = useRef(null); @@ -141,6 +144,7 @@ const CommonMember: FC = ({ onClose={onClose} isShowing={isShowing} avatar={avatar} + directParent={directParent} /> ); diff --git a/src/pages/OldCommon/store/api.tsx b/src/pages/OldCommon/store/api.tsx index a058193f82..8d747a66ec 100644 --- a/src/pages/OldCommon/store/api.tsx +++ b/src/pages/OldCommon/store/api.tsx @@ -17,7 +17,11 @@ import { } from "@/pages/OldCommon/interfaces"; import { CreateDiscussionMessageDto } from "@/pages/OldCommon/interfaces"; import Api from "@/services/Api"; -import { AllocateFundsTo, ApiEndpoint } from "@/shared/constants"; +import { + AllocateFundsTo, + ApiEndpoint, + ProposalsTypes, +} from "@/shared/constants"; import { ModerationFlags } from "@/shared/interfaces/Moderation"; import { SubscriptionUpdateData } from "@/shared/interfaces/api/subscription"; import { @@ -46,6 +50,7 @@ import { Vote, VoteWithUserInfo, CommonMemberPreviewInfo, + DirectParent, } from "@/shared/models"; import { BankAccountDetails as AddBankDetailsPayload } from "@/shared/models/BankAccountDetails"; import { NotificationItem } from "@/shared/models/Notification"; @@ -200,19 +205,40 @@ export async function fetchUserProposals(userId: string) { ); } +/** + * For a space: + * 1. The commonId needs to be the direct parent id and not the space id. + * 2. circleId of the direct parent is required. + */ export async function fetchUserMemberAdmittanceProposalWithCommonId( userId: string, commonId: string, + directParent?: DirectParent | null, ) { - const proposal = await firebase + let proposal = firebase .firestore() .collection(Collection.Proposals) .where("data.args.proposerId", "==", userId) - .where("data.args.commonId", "==", commonId) - .where("type", "==", "MEMBER_ADMITTANCE") - .get(); + .where("data.args.commonId", "==", directParent?.commonId ?? commonId) + .where( + "type", + "==", + directParent?.circleId + ? ProposalsTypes.ASSIGN_CIRCLE + : ProposalsTypes.MEMBER_ADMITTANCE, + ); + + if (directParent?.circleId) { + proposal = proposal.where( + "data.args.circleId", + "==", + directParent.circleId, + ); + } + + const res = await proposal.get(); - return transformFirebaseDataList(proposal)[0]; + return transformFirebaseDataList(res)[0]; } export async function fetchCommonList(): Promise { diff --git a/src/pages/common/components/ChatComponent/ChatComponent.tsx b/src/pages/common/components/ChatComponent/ChatComponent.tsx index 32bb4a81f3..6a48414ed2 100644 --- a/src/pages/common/components/ChatComponent/ChatComponent.tsx +++ b/src/pages/common/components/ChatComponent/ChatComponent.tsx @@ -31,6 +31,7 @@ import { Circles, CommonFeedObjectUserUnique, CommonMember, + DirectParent, Discussion, DiscussionMessage, Timestamp, @@ -85,6 +86,7 @@ interface ChatComponentInterface { isAuthorized?: boolean; isHidden: boolean; onMessagesAmountChange?: (newMessagesAmount: number) => void; + directParent?: DirectParent | null; } interface Messages { @@ -122,6 +124,7 @@ export default function ChatComponent({ isHidden = false, isCommonMemberFetched, onMessagesAmountChange, + directParent, }: ChatComponentInterface) { const dispatch = useDispatch(); useZoomDisabling(); @@ -589,6 +592,7 @@ export default function ChatComponent({ feedItemId={feedItemId} isLoading={isLoadingDiscussionMessages} onMessageDelete={handleMessageDelete} + directParent={directParent} /> {isAuthorized && ( diff --git a/src/pages/common/components/ChatComponent/components/ChatContent/ChatContent.tsx b/src/pages/common/components/ChatComponent/components/ChatContent/ChatContent.tsx index ad4b350903..bde28885b0 100644 --- a/src/pages/common/components/ChatComponent/components/ChatContent/ChatContent.tsx +++ b/src/pages/common/components/ChatComponent/components/ChatContent/ChatContent.tsx @@ -20,6 +20,7 @@ import { checkIsUserDiscussionMessage, CommonFeedObjectUserUnique, CommonMember, + DirectParent, DiscussionMessage, User, } from "@/shared/models"; @@ -49,6 +50,7 @@ interface ChatContentInterface { feedItemId: string; isLoading: boolean; onMessageDelete?: (messageId: string) => void; + directParent?: DirectParent | null; } const isToday = (someDate: Date) => { @@ -81,6 +83,7 @@ const ChatContent: ForwardRefRenderFunction< feedItemId, isLoading, onMessageDelete, + directParent, }, chatContentRef, ) => { @@ -255,6 +258,7 @@ const ChatContent: ForwardRefRenderFunction< feedItemId={feedItemId} commonMember={commonMember} onMessageDelete={onMessageDelete} + directParent={directParent} /> ); diff --git a/src/pages/common/components/CommonTabPanels/components/FeedTab/FeedTab.tsx b/src/pages/common/components/CommonTabPanels/components/FeedTab/FeedTab.tsx index cec2d794c6..4e66190913 100644 --- a/src/pages/common/components/CommonTabPanels/components/FeedTab/FeedTab.tsx +++ b/src/pages/common/components/CommonTabPanels/components/FeedTab/FeedTab.tsx @@ -137,6 +137,7 @@ export const FeedTab: FC = (props) => { feedItemId={chatItem.feedItemId} lastSeenItem={chatItem.lastSeenItem} seenOnce={chatItem.seenOnce} + directParent={common.directParent} /> )} @@ -170,6 +171,7 @@ export const FeedTab: FC = (props) => { discussion={chatItem.discussion} feedItemId={chatItem.feedItemId} lastSeenItem={chatItem.lastSeenItem} + directParent={common.directParent} /> )} diff --git a/src/pages/common/components/CommonTabPanels/components/MembersTab/MembersTab.tsx b/src/pages/common/components/CommonTabPanels/components/MembersTab/MembersTab.tsx index 60ab013d1a..32cfe04f2c 100644 --- a/src/pages/common/components/CommonTabPanels/components/MembersTab/MembersTab.tsx +++ b/src/pages/common/components/CommonTabPanels/components/MembersTab/MembersTab.tsx @@ -15,7 +15,6 @@ interface MembersTabProps { export const MembersTab: FC = (props) => { const { activeTab, common, commonMember } = props; - return (
@@ -25,6 +24,7 @@ export const MembersTab: FC = (props) => { governanceId={common.governanceId} commonMember={commonMember} isProject={checkIsProject(common)} + directParent={common.directParent} />
diff --git a/src/pages/common/components/CommonTabPanels/components/MembersTab/components/Members/Members.tsx b/src/pages/common/components/CommonTabPanels/components/MembersTab/components/Members/Members.tsx index 3ddb937fd4..e0549fa662 100644 --- a/src/pages/common/components/CommonTabPanels/components/MembersTab/components/Members/Members.tsx +++ b/src/pages/common/components/CommonTabPanels/components/MembersTab/components/Members/Members.tsx @@ -1,7 +1,11 @@ import React, { FC, useEffect, useMemo } from "react"; import classNames from "classnames"; import { useCommonMembers } from "@/pages/OldCommon/hooks"; -import { CirclesPermissions, CommonMember } from "@/shared/models"; +import { + CirclesPermissions, + CommonMember, + DirectParent, +} from "@/shared/models"; import { Loader } from "@/shared/ui-kit"; import { MembersList } from "../MembersList"; @@ -10,10 +14,12 @@ interface MembersComponentProps { governanceId: string | null; commonMember: (CommonMember & CirclesPermissions) | null; isProject: boolean; + directParent?: DirectParent | null; } const MembersComponent: FC = (props) => { - const { commonId, governanceId, commonMember, isProject } = props; + const { commonId, governanceId, commonMember, isProject, directParent } = + props; const { fetched: areCommonMembersFetched, data: commonMembers, @@ -49,6 +55,7 @@ const MembersComponent: FC = (props) => { governanceId={governanceId} commonMember={commonMember} isProject={isProject} + directParent={directParent} /> )} diff --git a/src/pages/common/components/CommonTabPanels/components/MembersTab/components/MembersList/MembersList.tsx b/src/pages/common/components/CommonTabPanels/components/MembersTab/components/MembersList/MembersList.tsx index b7ce542e3d..5a6790f9a5 100644 --- a/src/pages/common/components/CommonTabPanels/components/MembersTab/components/MembersList/MembersList.tsx +++ b/src/pages/common/components/CommonTabPanels/components/MembersTab/components/MembersList/MembersList.tsx @@ -2,7 +2,11 @@ import React, { FC, memo, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import CommonMember from "@/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent"; import { useGovernance } from "@/shared/hooks/useCases"; -import { CirclesPermissions, CommonMemberWithUserInfo } from "@/shared/models"; +import { + CirclesPermissions, + CommonMemberWithUserInfo, + DirectParent, +} from "@/shared/models"; import { CommonMember as CommonMemberModel } from "@/shared/models"; import { Loader } from "@/shared/ui-kit"; import { commonActions, selectRecentAssignedCircle } from "@/store/states"; @@ -14,6 +18,7 @@ interface MembersListComponentProps { governanceId: string | null; commonMember: (CommonMemberModel & CirclesPermissions) | null; isProject: boolean; + directParent?: DirectParent | null; } const MembersList: FC = ({ @@ -22,6 +27,7 @@ const MembersList: FC = ({ governanceId, commonMember, isProject, + directParent, }) => { const { data: governance, @@ -63,6 +69,7 @@ const MembersList: FC = ({ commonMember={commonMember} governanceCircles={governanceCircles} isProject={isProject} + directParent={directParent} /> ); })} diff --git a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx index ff954023ff..9d46a87499 100644 --- a/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx +++ b/src/pages/common/components/DiscussionFeedCard/DiscussionFeedCard.tsx @@ -15,6 +15,7 @@ import { Common, CommonFeed, CommonMember, + DirectParent, Governance, PredefinedTypes, } from "@/shared/models"; @@ -49,6 +50,7 @@ interface DiscussionFeedCardProps { getLastMessage: (options: GetLastMessageOptions) => TextEditorValue; getNonAllowedItems?: GetNonAllowedItemsOptions; onActiveItemDataChange?: (data: FeedLayoutItemChangeData) => void; + directParent?: DirectParent | null; } const DiscussionFeedCard: FC = (props) => { @@ -72,6 +74,7 @@ const DiscussionFeedCard: FC = (props) => { getLastMessage, getNonAllowedItems, onActiveItemDataChange, + directParent, } = props; const { isShowing: isReportModalOpen, @@ -238,6 +241,7 @@ const DiscussionFeedCard: FC = (props) => { isMobileVersion={isMobileVersion} commonId={commonId} userId={item.userId} + directParent={directParent} /> = (props) => { @@ -30,6 +32,7 @@ export const FeedCardHeader: React.FC = (props) => { isMobileVersion = false, commonId, userId, + directParent, } = props; const { isShowing: isShowingUserProfile, @@ -59,6 +62,7 @@ export const FeedCardHeader: React.FC = (props) => { avatar={avatar} isShowing={isShowingUserProfile} onClose={onCloseUserProfile} + directParent={directParent} /> )} diff --git a/src/pages/common/components/FeedItem/FeedItem.tsx b/src/pages/common/components/FeedItem/FeedItem.tsx index 218d91527e..9766caa49f 100644 --- a/src/pages/common/components/FeedItem/FeedItem.tsx +++ b/src/pages/common/components/FeedItem/FeedItem.tsx @@ -6,6 +6,7 @@ import { CommonFeed, CommonFeedType, CommonMember, + DirectParent, } from "@/shared/models"; import { checkIsItemVisibleForUser } from "@/shared/utils"; import { useFeedItemSubscription } from "../../hooks"; @@ -33,6 +34,7 @@ interface FeedItemProps { sizeKey?: string; shouldCheckItemVisibility?: boolean; onActiveItemDataChange?: (data: FeedLayoutItemChangeData) => void; + directParent?: DirectParent | null; } const FeedItem: FC = (props) => { @@ -55,6 +57,7 @@ const FeedItem: FC = (props) => { currentUserId, shouldCheckItemVisibility = true, onActiveItemDataChange, + directParent, } = props; const { onFeedItemUpdate, getLastMessage, getNonAllowedItems } = useFeedItemContext(); @@ -89,6 +92,7 @@ const FeedItem: FC = (props) => { getNonAllowedItems, isMobileVersion, onActiveItemDataChange, + directParent, }; if (item.data.type === CommonFeedType.Discussion) { diff --git a/src/pages/common/components/FeedItems/FeedItems.tsx b/src/pages/common/components/FeedItems/FeedItems.tsx index 4e256c0aed..c2119d721a 100644 --- a/src/pages/common/components/FeedItems/FeedItems.tsx +++ b/src/pages/common/components/FeedItems/FeedItems.tsx @@ -82,6 +82,7 @@ const FeedItems: FC = (props) => { isMobileVersion={isTabletView} userCircleIds={userCircleIds} isPreviewMode + directParent={common.directParent} /> ); })} diff --git a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx index ee5180037e..2634b88adc 100644 --- a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx +++ b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx @@ -410,6 +410,7 @@ const FeedLayout: ForwardRefRenderFunction = ( onActiveItemDataChange={(...args) => handleActiveFeedItemDataChange(...args, commonData?.id) } + directParent={outerCommon?.directParent} /> ); } @@ -462,6 +463,7 @@ const FeedLayout: ForwardRefRenderFunction = ( shouldShowSeeMore={!chatItem?.chatChannel && shouldShowSeeMore} rightHeaderContent={followFeedItemEl} onMessagesAmountChange={handleMessagesAmountChange} + directParent={outerCommon?.directParent} > {selectedItemCommonData && checkIsFeedItemFollowLayoutItem(selectedFeedItem) && ( diff --git a/src/pages/commonFeed/components/FeedLayout/components/MobileChat/MobileChat.tsx b/src/pages/commonFeed/components/FeedLayout/components/MobileChat/MobileChat.tsx index 7603b4d4ad..a6481c02ae 100644 --- a/src/pages/commonFeed/components/FeedLayout/components/MobileChat/MobileChat.tsx +++ b/src/pages/commonFeed/components/FeedLayout/components/MobileChat/MobileChat.tsx @@ -10,7 +10,12 @@ import { import { checkHasAccessToChat } from "@/pages/common/components/CommonTabPanels/components"; import { ChatType } from "@/shared/constants"; import { useUserById } from "@/shared/hooks/useCases"; -import { Circles, CirclesPermissions, CommonMember } from "@/shared/models"; +import { + Circles, + CirclesPermissions, + CommonMember, + DirectParent, +} from "@/shared/models"; import { getUserName } from "@/shared/utils"; import { Header } from "./components"; import styles from "./MobileChat.module.scss"; @@ -25,6 +30,7 @@ interface ChatProps { shouldShowSeeMore?: boolean; rightHeaderContent?: ReactNode; onMessagesAmountChange?: (newMessagesAmount: number) => void; + directParent?: DirectParent | null; } const MobileChat: FC = (props) => { @@ -39,6 +45,7 @@ const MobileChat: FC = (props) => { shouldShowSeeMore = true, rightHeaderContent, onMessagesAmountChange, + directParent, } = props; const { setChatItem, setIsShowFeedItemDetailsModal, setShouldShowSeeMore } = useChatContext(); @@ -135,6 +142,7 @@ const MobileChat: FC = (props) => { lastSeenItem={chatItem.lastSeenItem} seenOnce={chatItem.seenOnce} onMessagesAmountChange={onMessagesAmountChange} + directParent={directParent} /> )} diff --git a/src/shared/components/Chat/ChatMessage/ChatMessage.tsx b/src/shared/components/Chat/ChatMessage/ChatMessage.tsx index 1bb7ad1e50..417a16b1d0 100644 --- a/src/shared/components/Chat/ChatMessage/ChatMessage.tsx +++ b/src/shared/components/Chat/ChatMessage/ChatMessage.tsx @@ -25,6 +25,7 @@ import { checkIsUserDiscussionMessage, DiscussionMessage, User, + DirectParent, } from "@/shared/models"; import { FilePreview, @@ -57,6 +58,7 @@ interface ChatMessageProps { feedItemId: string; commonMember: CommonMember | null; onMessageDelete?: (messageId: string) => void; + directParent?: DirectParent | null; } const getStaticLinkByChatType = (chatType: ChatType): StaticLinkType => { @@ -83,6 +85,7 @@ export default function ChatMessage({ feedItemId, commonMember, onMessageDelete, + directParent, }: ChatMessageProps) { const messageRef = useRef(null); const { getCommonPagePath, getCommonPageAboutTabPath } = useRoutesContext(); @@ -424,6 +427,7 @@ export default function ChatMessage({ avatar={discussionMessage.ownerAvatar} isShowing={isShowingUserProfile} onClose={onCloseUserProfile} + directParent={directParent} /> )} diff --git a/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx b/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx index 729e758752..3e52e523aa 100644 --- a/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx +++ b/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx @@ -2,7 +2,7 @@ import React, { FC } from "react"; import classNames from "classnames"; import { UserInfoPopup } from "@/shared/components"; import { useModal } from "@/shared/hooks"; -import { User } from "@/shared/models"; +import { DirectParent, User } from "@/shared/models"; import { getUserName } from "@/shared/utils"; import styles from "../../ChatMessage.module.scss"; @@ -12,10 +12,18 @@ interface UserMentionProps { displayName: string; mentionTextClassName?: string; commonId?: string; + directParent: DirectParent; } const UserMention: FC = (props) => { - const { users, userId, displayName, mentionTextClassName, commonId } = props; + const { + users, + userId, + displayName, + mentionTextClassName, + commonId, + directParent, + } = props; const { isShowing: isShowingUserProfile, onClose: onCloseUserProfile, @@ -41,6 +49,7 @@ const UserMention: FC = (props) => { onClose={onCloseUserProfile} commonId={commonId} userId={user?.uid} + directParent={directParent} /> ); diff --git a/src/shared/components/UserInfoPopup/UserInfoPopup.tsx b/src/shared/components/UserInfoPopup/UserInfoPopup.tsx index 83a577c673..f56c97fd20 100644 --- a/src/shared/components/UserInfoPopup/UserInfoPopup.tsx +++ b/src/shared/components/UserInfoPopup/UserInfoPopup.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react"; import { fetchUserMemberAdmittanceProposalWithCommonId } from "@/pages/OldCommon/store/api"; import { getCountryNameFromCode } from "@/shared/assets/countries"; import { useCommonMemberWithUserInfo } from "@/shared/hooks/useCases"; -import { Proposal } from "@/shared/models"; +import { DirectParent, Proposal } from "@/shared/models"; import { Loader } from "../Loader"; import { Modal } from "../Modal"; import { UserAvatar } from "../UserAvatar"; @@ -14,6 +14,7 @@ interface UserInfoPopupProps { avatar?: string; isShowing: boolean; onClose: () => void; + directParent?: DirectParent | null; } const UserInfoPopup = ({ @@ -22,6 +23,7 @@ const UserInfoPopup = ({ avatar, isShowing, onClose, + directParent, }: UserInfoPopupProps) => { const { data, fetched } = useCommonMemberWithUserInfo(commonId, userId); const [memberAdmittanceProposal, setMemberAdmittanceProposal] = @@ -33,6 +35,7 @@ const UserInfoPopup = ({ const proposal = await fetchUserMemberAdmittanceProposalWithCommonId( userId, commonId, + directParent, ); setMemberAdmittanceProposal(proposal); } diff --git a/src/shared/models/Common.tsx b/src/shared/models/Common.tsx index 993f3456d5..0925381b9f 100644 --- a/src/shared/models/Common.tsx +++ b/src/shared/models/Common.tsx @@ -13,7 +13,7 @@ import { } from "./governance/Circles"; import { Time } from "./shared"; -interface DirectParent { +export interface DirectParent { commonId: string; circleId: string; } From c6c5f9e66e8cbb21c1df7f465002f425b0572b36 Mon Sep 17 00:00:00 2001 From: Roie Natan Date: Wed, 26 Jul 2023 09:01:31 +1300 Subject: [PATCH 2/3] show space intro also when clicking on user mentions in chat --- .../commonFeed/components/FeedLayout/FeedLayout.tsx | 1 + .../FeedLayout/components/DesktopChat/DesktopChat.tsx | 10 +++++++++- src/shared/components/Chat/ChatMessage/ChatMessage.tsx | 2 ++ .../ChatMessage/components/UserMention/UserMention.tsx | 2 +- src/shared/components/Chat/ChatMessage/types.ts | 3 ++- .../ChatMessage/utils/getTextFromSystemMessage.tsx | 2 ++ .../ChatMessage/utils/getTextFromTextEditorString.tsx | 8 +++++++- 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx index 2634b88adc..2098b7249d 100644 --- a/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx +++ b/src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx @@ -445,6 +445,7 @@ const FeedLayout: ForwardRefRenderFunction = ( withTitle={settings?.withDesktopChatTitle} titleRightContent={followFeedItemEl} onMessagesAmountChange={handleMessagesAmountChange} + directParent={outerCommon?.directParent} /> ) : ( void; + directParent?: DirectParent | null; } const DesktopChat: FC = (props) => { @@ -35,6 +41,7 @@ const DesktopChat: FC = (props) => { withTitle = true, titleRightContent, onMessagesAmountChange, + directParent, } = props; const { fetchUser: fetchDMUser, @@ -105,6 +112,7 @@ const DesktopChat: FC = (props) => { isHidden={false} isAuthorized={Boolean(user)} onMessagesAmountChange={onMessagesAmountChange} + directParent={directParent} /> ); diff --git a/src/shared/components/Chat/ChatMessage/ChatMessage.tsx b/src/shared/components/Chat/ChatMessage/ChatMessage.tsx index 417a16b1d0..196d0b0b79 100644 --- a/src/shared/components/Chat/ChatMessage/ChatMessage.tsx +++ b/src/shared/components/Chat/ChatMessage/ChatMessage.tsx @@ -149,6 +149,7 @@ export default function ChatMessage({ systemMessage: isSystemMessage ? discussionMessage : undefined, getCommonPagePath, getCommonPageAboutTabPath, + directParent: directParent, }); setMessageText(parsedText); @@ -173,6 +174,7 @@ export default function ChatMessage({ textEditorString: discussionMessage?.parentMessage.text, users, commonId: discussionMessage.commonId, + directParent: directParent, }); setReplyMessageText(parsedText); diff --git a/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx b/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx index 3e52e523aa..a31635096c 100644 --- a/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx +++ b/src/shared/components/Chat/ChatMessage/components/UserMention/UserMention.tsx @@ -12,7 +12,7 @@ interface UserMentionProps { displayName: string; mentionTextClassName?: string; commonId?: string; - directParent: DirectParent; + directParent?: DirectParent | null; } const UserMention: FC = (props) => { diff --git a/src/shared/components/Chat/ChatMessage/types.ts b/src/shared/components/Chat/ChatMessage/types.ts index f76aaf9877..c7cd14d589 100644 --- a/src/shared/components/Chat/ChatMessage/types.ts +++ b/src/shared/components/Chat/ChatMessage/types.ts @@ -1,4 +1,4 @@ -import { SystemDiscussionMessage, User } from "@/shared/models"; +import { DirectParent, SystemDiscussionMessage, User } from "@/shared/models"; import { GetCommonPageAboutTabPath, GetCommonPagePath } from "@/shared/utils"; export type Text = string | JSX.Element; @@ -15,4 +15,5 @@ export interface TextData { >; getCommonPagePath?: GetCommonPagePath; getCommonPageAboutTabPath?: GetCommonPageAboutTabPath; + directParent?: DirectParent | null; } diff --git a/src/shared/components/Chat/ChatMessage/utils/getTextFromSystemMessage.tsx b/src/shared/components/Chat/ChatMessage/utils/getTextFromSystemMessage.tsx index 1e967cf24e..04b6f7cc5f 100644 --- a/src/shared/components/Chat/ChatMessage/utils/getTextFromSystemMessage.tsx +++ b/src/shared/components/Chat/ChatMessage/utils/getTextFromSystemMessage.tsx @@ -7,6 +7,7 @@ import { CommonCreatedSystemMessage, CommonEditedSystemMessage, CommonMemberAddedSystemMessage, + DirectParent, SystemMessageCommonType, User, } from "@/shared/models"; @@ -41,6 +42,7 @@ const renderUserMention = ( displayName={getUserName(user)} mentionTextClassName={data.mentionTextClassName} commonId={data.commonId} + directParent={data.directParent} /> ) : ( defaultName diff --git a/src/shared/components/Chat/ChatMessage/utils/getTextFromTextEditorString.tsx b/src/shared/components/Chat/ChatMessage/utils/getTextFromTextEditorString.tsx index f4ff62bd83..ad8b2c5f58 100644 --- a/src/shared/components/Chat/ChatMessage/utils/getTextFromTextEditorString.tsx +++ b/src/shared/components/Chat/ChatMessage/utils/getTextFromTextEditorString.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Descendant, Element } from "slate"; import { UserService } from "@/services"; -import { User } from "@/shared/models"; +import { DirectParent, User } from "@/shared/models"; import { getMentionTags, parseStringToTextEditorValue, @@ -27,6 +27,7 @@ interface TextFromDescendant { mentionTextClassName?: string; emojiTextClassName?: string; commonId?: string; + directParent?: DirectParent | null; } const getTextFromDescendant = ({ @@ -35,6 +36,7 @@ const getTextFromDescendant = ({ mentionTextClassName, emojiTextClassName, commonId, + directParent, }: TextFromDescendant): Text => { if (!Element.isElement(descendant)) { return descendant.text || ""; @@ -53,6 +55,7 @@ const getTextFromDescendant = ({ mentionTextClassName, emojiTextClassName, commonId, + directParent, })} ))} @@ -67,6 +70,7 @@ const getTextFromDescendant = ({ displayName={descendant.displayName} mentionTextClassName={mentionTextClassName} commonId={commonId} + directParent={directParent} /> ); case ElementType.Emoji: @@ -91,6 +95,7 @@ export const getTextFromTextEditorString = async ( emojiTextClassName, commonId, systemMessage, + directParent, } = data; if (systemMessage) { @@ -125,6 +130,7 @@ export const getTextFromTextEditorString = async ( mentionTextClassName, emojiTextClassName, commonId, + directParent, })} , ], From e26e46fa0dfca1c3833bffd056067089e8abfef8 Mon Sep 17 00:00:00 2001 From: Andrey Mikhadyuk Date: Wed, 26 Jul 2023 20:40:02 +0400 Subject: [PATCH 3/3] rename proposal query variable --- src/pages/OldCommon/store/api.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/OldCommon/store/api.tsx b/src/pages/OldCommon/store/api.tsx index 8d747a66ec..0af0b8244c 100644 --- a/src/pages/OldCommon/store/api.tsx +++ b/src/pages/OldCommon/store/api.tsx @@ -215,7 +215,7 @@ export async function fetchUserMemberAdmittanceProposalWithCommonId( commonId: string, directParent?: DirectParent | null, ) { - let proposal = firebase + let proposalQuery = firebase .firestore() .collection(Collection.Proposals) .where("data.args.proposerId", "==", userId) @@ -229,16 +229,16 @@ export async function fetchUserMemberAdmittanceProposalWithCommonId( ); if (directParent?.circleId) { - proposal = proposal.where( + proposalQuery = proposalQuery.where( "data.args.circleId", "==", directParent.circleId, ); } - const res = await proposal.get(); + const proposal = await proposalQuery.get(); - return transformFirebaseDataList(res)[0]; + return transformFirebaseDataList(proposal)[0]; } export async function fetchCommonList(): Promise {