fix(chat-item): selected chat-item showing border in other pages

This commit is contained in:
Eric Huang 2023-12-15 09:37:37 +08:00
parent cae4655785
commit 943a2707d2
1 changed files with 6 additions and 2 deletions

View File

@ -12,7 +12,7 @@ import {
import { useChatStore } from "../store";
import Locale from "../locales";
import { Link, useNavigate } from "react-router-dom";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { Path } from "../constant";
import { MaskAvatar } from "./mask";
import { Mask } from "../store/mask";
@ -40,12 +40,16 @@ export function ChatItem(props: {
});
}
}, [props.selected]);
const { pathname: currentPath } = useLocation();
return (
<Draggable draggableId={`${props.id}`} index={props.index}>
{(provided) => (
<div
className={`${styles["chat-item"]} ${
props.selected && styles["chat-item-selected"]
props.selected &&
(currentPath === Path.Chat || currentPath === Path.Home) &&
styles["chat-item-selected"]
}`}
onClick={props.onClick}
ref={(ele) => {