Skip to content

Commit

Permalink
Merge pull request #202 from aitok-ai/zhaoyu/issue-118
Browse files Browse the repository at this point in the history
Temporarily removed the liked conversation button
  • Loading branch information
jinzishuai authored May 27, 2024
2 parents 28b17b3 + 1da10f3 commit 5e42326
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
62 changes: 31 additions & 31 deletions client/src/components/Messages/MessageHeaderButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import PrivateButton from '../Conversations/PrivateButton';
import { CSSTransition } from 'react-transition-group';
import store from '~/store';
import { useAuthContext } from '~/hooks/AuthContext';
import {
useLikeConversationMutation,
// useUpdateConversationMutation,
} from 'librechat-data-provider/react-query';
// import {
// useLikeConversationMutation,
// // useUpdateConversationMutation,
// } from 'librechat-data-provider/react-query';
import { useUpdateConversationMutation } from '~/data-provider';
import { useLocalize } from '~/hooks';

Expand All @@ -19,15 +19,15 @@ export default function MessageHeaderButtons({ conversationId, index = 0 }) {
// const conversation = useRecoilValue(store.conversation);
// const { conversationId } = conversation;
const updateConvoMutation = useUpdateConversationMutation(conversation?.conversationId);
const likeConvoMutation = useLikeConversationMutation(conversation?.conversationId);
// const likeConvoMutation = useLikeConversationMutation(conversation?.conversationId);
const { viewCount } = conversation;

// UI states
const [privateState, setPrivateState] = useState(false);
const [copied, setCopied] = useState(false);
const [liked, setLiked] = useState(false);
const [numOfLikes, setNumOfLikes] = useState(0);
const [likedBy, setLikedBy] = useState({});
// const [liked, setLiked] = useState(false);
// const [numOfLikes, setNumOfLikes] = useState(0);
// const [likedBy, setLikedBy] = useState({});

// Copies conversation share link
const copyShareLinkHandler = () => {
Expand All @@ -49,33 +49,33 @@ export default function MessageHeaderButtons({ conversationId, index = 0 }) {
};

// Likes the conversation
const likeHandler = async () => {
// update component state
setLiked(!liked);
// const likeHandler = async () => {
// // update component state
// setLiked(!liked);

// Initiate these properties if they do not exist
if (!likedBy) {
setLikedBy({});
}
// // Initiate these properties if they do not exist
// if (!likedBy) {
// setLikedBy({});
// }

// update states
if (liked) {
delete likedBy[user.id];
setNumOfLikes(numOfLikes - 1);
} else {
likedBy[user.id] = new Date();
setNumOfLikes(numOfLikes + 1);
}
// // update states
// if (liked) {
// delete likedBy[user.id];
// setNumOfLikes(numOfLikes - 1);
// } else {
// likedBy[user.id] = new Date();
// setNumOfLikes(numOfLikes + 1);
// }

// update DB
likeConvoMutation.mutate({ conversationId: conversationId, userId: user.id, liked: !liked });
};
// // update DB
// likeConvoMutation.mutate({ conversationId: conversationId, userId: user.id, liked: !liked });
// };

useEffect(() => {
setLiked(conversation.likedBy && conversation.likedBy[user.id] ? true : false);
setNumOfLikes(conversation.likes);
// setLiked(conversation.likedBy && conversation.likedBy[user.id] ? true : false);
// setNumOfLikes(conversation.likes);
setPrivateState(conversation.isPrivate);
setLikedBy({ ...(conversation.likedBy || {}) });
// setLikedBy({ ...(conversation.likedBy || {}) });
}, [conversation, user.id]);

return (
Expand Down Expand Up @@ -113,7 +113,7 @@ export default function MessageHeaderButtons({ conversationId, index = 0 }) {
<PrivateButton isPrivate={privateState} setPrivateHandler={setPrivateHandler} />

{/*Like button and number of likes*/}
<button
{/* <button
className="ml-0.5 flex flex-row items-center gap-1 pr-1 hover:bg-gray-200 hover:dark:bg-gray-600"
onClick={likeHandler}
>
Expand All @@ -136,7 +136,7 @@ export default function MessageHeaderButtons({ conversationId, index = 0 }) {
<div>
{localize('com_ui_number_of_likes', numOfLikes ? numOfLikes.toString() : '0')}
</div>
</button>
</button> */}
{/*View Count Display*/}
<div>{localize('com_ui_number_of_views', viewCount ? viewCount.toString() : '0')}</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function ProfileContent() {

useEffect(() => {
if (userId === user?.id) {
setTabValue('likes');
setTabValue('followers');
} else {
setTabValue('conversations');
}
Expand Down Expand Up @@ -625,11 +625,11 @@ function ProfileContent() {
className={defaultClasses}
>
<TabsList className="rounded-lg bg-blue-500 dark:bg-blue-500">
{userId === user?.id && (
{/* {userId === user?.id && (
<TabsTrigger value="likes" className="px-4 py-2 text-white dark:text-white">
{localize('com_ui_my_likes')}
</TabsTrigger>
)}
)} */}
{userId != user?.id && (
<TabsTrigger value="conversations" className="px-4 py-2 text-white dark:text-white">
{localize('com_ui_conversations')}
Expand Down

0 comments on commit 5e42326

Please sign in to comment.