From 7fb0bfbdc7493469efea767694e557413be77f60 Mon Sep 17 00:00:00 2001
From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com>
Date: Tue, 16 Nov 2021 20:18:58 +0100
Subject: [PATCH] Contact renaming (#131)
---
.../src/components/Chat/ChatMessages.tsx | 57 ++++-
.../src/components/Form/ContactMenu.tsx | 32 ++-
.../src/components/Icons/ClearIcon.tsx | 9 +-
.../src/components/Modals/ModalStyle.ts | 2 +
.../src/components/Modals/ProfileModal.tsx | 225 ++++++++++++++----
.../react-chat/src/components/ReactChat.tsx | 17 +-
6 files changed, 277 insertions(+), 65 deletions(-)
diff --git a/packages/react-chat/src/components/Chat/ChatMessages.tsx b/packages/react-chat/src/components/Chat/ChatMessages.tsx
index c04c9322..44a319a1 100644
--- a/packages/react-chat/src/components/Chat/ChatMessages.tsx
+++ b/packages/react-chat/src/components/Chat/ChatMessages.tsx
@@ -28,6 +28,9 @@ type ChatUiMessageProps = {
setImage: (img: string) => void;
setLink: (link: string) => void;
setUser: (user: string) => void;
+ customName?: string;
+ trueName?: string;
+ setRenaming: (val: boolean) => void;
};
function ChatUiMessage({
@@ -37,6 +40,9 @@ function ChatUiMessage({
setImage,
setLink,
setUser,
+ customName,
+ trueName,
+ setRenaming,
}: ChatUiMessageProps) {
const [showMenu, setShowMenu] = useState(false);
const [isUntrustworthy, setIsUntrustworthy] = useState(false);
@@ -63,6 +69,9 @@ function ChatUiMessage({
setShowMenu={setShowMenu}
isUntrustworthy={isUntrustworthy}
setIsUntrustworthy={setIsUntrustworthy}
+ customName={customName}
+ trueName={trueName}
+ setRenaming={setRenaming}
/>
)}
@@ -71,7 +80,15 @@ function ChatUiMessage({
- {message.sender.slice(0, 10)}
+
+ {" "}
+ {customName ? customName : message.sender.slice(0, 10)}
+
+ {customName && (
+
+ {message.sender.slice(0, 5)}...{message.sender.slice(-3)}
+
+ )}
{isUntrustworthy && }
{message.date.toLocaleString()}
@@ -119,11 +136,23 @@ export function ChatMessages() {
);
useEffect(() => (!showLinkModal ? setLink("") : undefined), [showLinkModal]);
+ const [renaming, setRenaming] = useState(false);
+ const [customName, setCustomName] = useState("");
+ const [trueName, setTrueName] = useState("");
+
return (
-
+
{loadingMessages && (
@@ -139,6 +168,9 @@ export function ChatMessages() {
setLink={setLink}
setImage={setImage}
setUser={setUser}
+ customName={customName}
+ trueName={trueName}
+ setRenaming={setRenaming}
/>
))}
@@ -226,6 +258,27 @@ const UserName = styled.p`
${textMediumStyles}
`;
+export const UserAddress = styled.p`
+ font-size: 10px;
+ line-height: 14px;
+ letter-spacing: 0.2px;
+ color: ${({ theme }) => theme.secondary};
+ position: relative;
+ padding-right: 8px;
+
+ &:after {
+ content: "";
+ position: absolute;
+ right: 0;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 4px;
+ height: 4px;
+ border-radius: 50%;
+ background: ${({ theme }) => theme.secondary};
+ }
+`;
+
const TimeWrapper = styled.div`
font-size: 10px;
line-height: 14px;
diff --git a/packages/react-chat/src/components/Form/ContactMenu.tsx b/packages/react-chat/src/components/Form/ContactMenu.tsx
index 7378b871..a9c73a87 100644
--- a/packages/react-chat/src/components/Form/ContactMenu.tsx
+++ b/packages/react-chat/src/components/Form/ContactMenu.tsx
@@ -5,7 +5,7 @@ import { useBlockedUsers } from "../../contexts/blockedUsersProvider";
import { useFriends } from "../../contexts/friendsProvider";
import { useModal } from "../../contexts/modalProvider";
import { ChatMessage } from "../../models/ChatMessage";
-import { Icon } from "../Chat/ChatMessages";
+import { Icon, UserAddress } from "../Chat/ChatMessages";
import { AddContactSvg } from "../Icons/AddContactIcon";
import { BlockSvg } from "../Icons/BlockIcon";
import { ChatSvg } from "../Icons/ChatIcon";
@@ -24,6 +24,9 @@ type ContactMenuProps = {
setShowMenu: (val: boolean) => void;
isUntrustworthy: boolean;
setIsUntrustworthy: (val: boolean) => void;
+ customName?: string;
+ trueName?: string;
+ setRenaming: (val: boolean) => void;
};
export function ContactMenu({
@@ -31,6 +34,9 @@ export function ContactMenu({
setShowMenu,
isUntrustworthy,
setIsUntrustworthy,
+ customName,
+ trueName,
+ setRenaming,
}: ContactMenuProps) {
const id = message.sender;
const { blockedUsers, setBlockedUsers } = useBlockedUsers();
@@ -59,9 +65,12 @@ export function ContactMenu({
)}
- {message.sender.slice(0, 10)}
+
+ {customName ? customName : message.sender.slice(0, 10)}
+
{isUntrustworthy && }
+ {trueName && ({trueName})}
{message.sender.slice(0, 10)}...{message.sender.slice(-3)}
@@ -83,7 +92,12 @@ export function ContactMenu({
Send Message
)}
-