From 34a8a0a899250c0ea05214dca4a631cbc96842e8 Mon Sep 17 00:00:00 2001
From: Maria Rushkova <66270386+mrushkova@users.noreply.github.com>
Date: Tue, 16 Nov 2021 08:44:40 +0100
Subject: [PATCH] Improve profile modal (#129)
---
.../src/components/Form/ContactMenu.tsx | 24 ++++++--
.../src/components/Icons/ChatIcon.tsx | 38 +++++++++++++
.../src/components/Modals/ProfileModal.tsx | 55 ++++++++++++++++++-
.../src/contexts/friendsProvider.tsx | 27 +++++++++
4 files changed, 137 insertions(+), 7 deletions(-)
create mode 100644 packages/react-chat/src/components/Icons/ChatIcon.tsx
create mode 100644 packages/react-chat/src/contexts/friendsProvider.tsx
diff --git a/packages/react-chat/src/components/Form/ContactMenu.tsx b/packages/react-chat/src/components/Form/ContactMenu.tsx
index c5597fde..7378b871 100644
--- a/packages/react-chat/src/components/Form/ContactMenu.tsx
+++ b/packages/react-chat/src/components/Form/ContactMenu.tsx
@@ -2,11 +2,13 @@ import React, { useMemo } from "react";
import styled from "styled-components";
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 { AddContactSvg } from "../Icons/AddContactIcon";
import { BlockSvg } from "../Icons/BlockIcon";
+import { ChatSvg } from "../Icons/ChatIcon";
import { EditSvg } from "../Icons/EditIcon";
import { ProfileSvg } from "../Icons/ProfileIcon";
import { UntrustworthIcon } from "../Icons/UntrustworthIcon";
@@ -38,6 +40,10 @@ export function ContactMenu({
[blockedUsers, id]
);
+ const { friends, setFriends } = useFriends();
+
+ const userIsFriend = useMemo(() => friends.includes(id), [friends, id]);
+
const { setModal } = useModal(ProfileModalName);
return (
@@ -65,10 +71,18 @@ export function ContactMenu({
View Profile
-
+ {!userIsFriend && (
+
+ )}
+ {userIsFriend && (
+
+ )}
- {!userInBlocked && (
+ {!userIsFriend && (