Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix click on user mention (old→new profile page) #2365 #2367

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default function ChatComponent({
multipleEmojiText: styles.multipleEmojiText,
},
onFeedItemClick,
onUserClick,
});
const {
chatMessagesData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ interface Return {
}

export const useDiscussionChatAdapter = (options: Options): Return => {
const { hasPermissionToHide, textStyles, discussionId, onFeedItemClick } =
options;
const {
hasPermissionToHide,
textStyles,
discussionId,
onFeedItemClick,
onUserClick,
} = options;
const user = useSelector(selectUser());
const userId = user?.uid;
const { data: commonMembers, fetchCommonMembers } = useCommonMembers();
Expand All @@ -46,6 +51,7 @@ export const useDiscussionChatAdapter = (options: Options): Return => {
users,
textStyles,
onFeedItemClick,
onUserClick,
});
const { markFeedItemAsSeen } = useMarkFeedItemAsSeen();

Expand Down
1 change: 0 additions & 1 deletion src/pages/commonFeed/CommonFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
import {
cacheActions,
commonActions,
commonLayoutActions,
selectCommonAction,
selectRecentStreamId,
selectSharedFeedItem,
Expand Down
25 changes: 1 addition & 24 deletions src/shared/components/Chat/ChatMessage/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ import React, {
import classNames from "classnames";
import { useLongPress } from "use-long-press";
import { DiscussionMessageService } from "@/services";
import {
ElementDropdown,
UserAvatar,
UserInfoPopup,
} from "@/shared/components";
import { ElementDropdown, UserAvatar } from "@/shared/components";
import {
Orientation,
ChatType,
EntityTypes,
QueryParamKey,
} from "@/shared/constants";
import { Colors } from "@/shared/constants";
import { useModal } from "@/shared/hooks";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { ModerationFlags } from "@/shared/interfaces/Moderation";
import {
Expand Down Expand Up @@ -146,17 +141,9 @@ export default function ChatMessage({
(discussionMessage.editedAt?.seconds ?? 0) * 1000,
);

const {
isShowing: isShowingUserProfile,
onClose: onCloseUserProfile,
onOpen: onOpenUserProfile,
} = useModal(false);

const handleUserClick = () => {
if (onUserClick && discussionMessageUserId) {
onUserClick(discussionMessageUserId);
} else {
onOpenUserProfile();
}
};

Expand Down Expand Up @@ -414,16 +401,6 @@ export default function ChatMessage({
</>
)}
</div>
{isShowingUserProfile && isUserDiscussionMessage && (
<UserInfoPopup
commonId={discussionMessage.commonId}
userId={discussionMessage.ownerId}
avatar={discussionMessage.ownerAvatar}
isShowing={isShowingUserProfile}
onClose={onCloseUserProfile}
directParent={directParent}
/>
)}
</li>
);
}
25 changes: 1 addition & 24 deletions src/shared/components/Chat/ChatMessage/DMChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import React, {
import classNames from "classnames";
import { useLongPress } from "use-long-press";
import { Logger } from "@/services";
import {
ElementDropdown,
UserAvatar,
UserInfoPopup,
} from "@/shared/components";
import { ElementDropdown, UserAvatar } from "@/shared/components";
import {
Orientation,
ChatType,
Expand All @@ -21,7 +17,6 @@ import {
} from "@/shared/constants";
import { Colors } from "@/shared/constants";
import { useRoutesContext } from "@/shared/contexts";
import { useModal } from "@/shared/hooks";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { ModerationFlags } from "@/shared/interfaces/Moderation";
import {
Expand Down Expand Up @@ -122,17 +117,9 @@ export default function DMChatMessage({
(discussionMessage.editedAt?.seconds ?? 0) * 1000,
);

const {
isShowing: isShowingUserProfile,
onClose: onCloseUserProfile,
onOpen: onOpenUserProfile,
} = useModal(false);

const handleUserClick = () => {
if (onUserClick && discussionMessageUserId) {
onUserClick(discussionMessageUserId);
} else {
onOpenUserProfile();
}
};

Expand Down Expand Up @@ -472,16 +459,6 @@ export default function DMChatMessage({
</>
)}
</div>
{isShowingUserProfile && isUserDiscussionMessage && (
<UserInfoPopup
commonId={discussionMessage.commonId}
userId={discussionMessage.ownerId}
avatar={discussionMessage.ownerAvatar}
isShowing={isShowingUserProfile}
onClose={onCloseUserProfile}
directParent={directParent}
/>
)}
</li>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { FC } from "react";
import classNames from "classnames";
import { UserInfoPopup } from "@/shared/components";
import { useModal } from "@/shared/hooks";
import { DirectParent, User } from "@/shared/models";
import { User } from "@/shared/models";
import { getUserName } from "@/shared/utils";
import styles from "../../ChatMessage.module.scss";

Expand All @@ -11,26 +9,13 @@ interface UserMentionProps {
userId: string;
displayName: string;
mentionTextClassName?: string;
commonId?: string;
directParent?: DirectParent | null;
onUserClick?: (userId: string) => void;
}

const UserMention: FC<UserMentionProps> = (props) => {
const {
users,
userId,
displayName,
mentionTextClassName,
commonId,
directParent,
onUserClick,
} = props;
const {
isShowing: isShowingUserProfile,
onClose: onCloseUserProfile,
onOpen: onOpenUserProfile,
} = useModal(false);
const { users, userId, displayName, mentionTextClassName, onUserClick } =
props;

const user = users.find(({ uid }) => uid === userId);
const withSpace = displayName[displayName.length - 1] === " ";
const userName = user
Expand All @@ -40,8 +25,6 @@ const UserMention: FC<UserMentionProps> = (props) => {
const handleUserNameClick = () => {
if (onUserClick) {
onUserClick(userId);
} else {
onOpenUserProfile();
}
};

Expand All @@ -53,16 +36,6 @@ const UserMention: FC<UserMentionProps> = (props) => {
>
@{userName}
</span>
{!onUserClick && (
<UserInfoPopup
avatar={user?.photoURL}
isShowing={isShowingUserProfile}
onClose={onCloseUserProfile}
commonId={commonId}
userId={user?.uid}
directParent={directParent}
/>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const renderUserMention = (
userId={user.uid}
displayName={getUserName(user)}
mentionTextClassName={data.mentionTextClassName}
commonId={data.commonId}
directParent={data.directParent}
onUserClick={data.onUserClick}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ const getTextFromDescendant = ({
userId={descendant.userId}
displayName={descendant.displayName}
mentionTextClassName={mentionTextClassName}
commonId={commonId}
directParent={directParent}
onUserClick={onUserClick}
/>
);
Expand Down
Loading