From 2e91024490f460cea925ab9ebb0b9e87e5bc144f Mon Sep 17 00:00:00 2001
From: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com>
Date: Wed, 22 Dec 2021 12:06:24 +0100
Subject: [PATCH] Show names in members (#160)
---
.../src/components/Chat/ChatInput.tsx | 5 ++--
.../src/components/Members/Member.tsx | 7 +++++-
.../src/components/Messages/MessageQuote.tsx | 8 +++++--
.../react-chat/src/components/SearchBlock.tsx | 24 ++++++++++---------
packages/status-communities/src/messenger.ts | 5 ----
5 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/packages/react-chat/src/components/Chat/ChatInput.tsx b/packages/react-chat/src/components/Chat/ChatInput.tsx
index ddb241fd..63f3d513 100644
--- a/packages/react-chat/src/components/Chat/ChatInput.tsx
+++ b/packages/react-chat/src/components/Chat/ChatInput.tsx
@@ -31,7 +31,7 @@ interface ChatInputProps {
}
export function ChatInput({ reply, setReply }: ChatInputProps) {
- const { sendMessage } = useMessengerContext();
+ const { sendMessage, contacts } = useMessengerContext();
const theme = useTheme() as Theme;
const [content, setContent] = useState("");
const [clearComponent, setClearComponent] = useState("");
@@ -254,7 +254,8 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
{" "}
{" "}
- {reply.sender}
+ {contacts[reply.sender]?.customName ??
+ contacts[reply.sender].trueName}
{reply.content}
{reply.image && }
diff --git a/packages/react-chat/src/components/Members/Member.tsx b/packages/react-chat/src/components/Members/Member.tsx
index e3c39652..e570ddd9 100644
--- a/packages/react-chat/src/components/Members/Member.tsx
+++ b/packages/react-chat/src/components/Members/Member.tsx
@@ -6,6 +6,7 @@ import { Contact } from "../../models/Contact";
import { ContactMenu } from "../Form/ContactMenu";
import { Icon } from "../Icons/Icon";
import { UserIcon } from "../Icons/UserIcon";
+import { UserAddress } from "../Messages/Styles";
interface MemberProps {
contact: Contact;
@@ -47,7 +48,10 @@ export function Member({
{showMenu && }
- {contact?.customName ?? contact.id}
+ {contact?.customName ?? contact.trueName}
+
+ {contact.id.slice(0, 5)}...{contact.id.slice(-3)}
+
);
}
@@ -69,6 +73,7 @@ export const MemberName = styled.p`
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
+ margin-right: 4px;
`;
export const MemberIcon = styled(Icon)`
diff --git a/packages/react-chat/src/components/Messages/MessageQuote.tsx b/packages/react-chat/src/components/Messages/MessageQuote.tsx
index 54dbaa6c..c006164a 100644
--- a/packages/react-chat/src/components/Messages/MessageQuote.tsx
+++ b/packages/react-chat/src/components/Messages/MessageQuote.tsx
@@ -1,6 +1,7 @@
import React, { useCallback } from "react";
import styled from "styled-components";
+import { useMessengerContext } from "../../contexts/messengerProvider";
import { ChatMessage } from "../../models/ChatMessage";
import { ReplyOn, ReplyTo } from "../Chat/ChatInput";
import { QuoteSvg } from "../Icons/QuoteIcon";
@@ -21,6 +22,7 @@ type MessageQuoteProps = {
};
export function MessageQuote({ quote }: MessageQuoteProps) {
+ const { contacts } = useMessengerContext();
const quoteClick = useCallback(() => {
if (quote) {
const quoteDiv = document.getElementById(quote.id);
@@ -42,13 +44,15 @@ export function MessageQuote({ quote }: MessageQuoteProps) {
}
}, [quote]);
- if (quote) {
+ if (quote && quote.sender) {
return (
{" "}
- {quote.sender}
+ {" "}
+ {contacts[quote.sender]?.customName ??
+ contacts[quote.sender].trueName}
{quote.content}
{quote.image && }
diff --git a/packages/react-chat/src/components/SearchBlock.tsx b/packages/react-chat/src/components/SearchBlock.tsx
index b493f99a..4f88b438 100644
--- a/packages/react-chat/src/components/SearchBlock.tsx
+++ b/packages/react-chat/src/components/SearchBlock.tsx
@@ -23,7 +23,12 @@ export const SearchBlock = ({
const searchList = useMemo(() => {
return Object.values(contacts)
- .filter((member) => member.id.includes(query))
+ .filter(
+ (member) =>
+ member.id.includes(query) ||
+ member?.customName?.includes(query) ||
+ member.trueName.includes(query)
+ )
.filter((member) => !discludeList.includes(member.id));
}, [query, discludeList, contacts]);
@@ -35,16 +40,13 @@ export const SearchBlock = ({
style={{ [onBotttom ? "bottom" : "top"]: "calc(100% + 24px)" }}
>
- {Object.values(contacts)
- .filter((member) => member.id.includes(query))
- .filter((member) => !discludeList.includes(member.id))
- .map((member) => (
- onClick(member.id)}
- />
- ))}
+ {searchList.map((member) => (
+ onClick(member.id)}
+ />
+ ))}
);
diff --git a/packages/status-communities/src/messenger.ts b/packages/status-communities/src/messenger.ts
index 1d9fc065..3d55bc6e 100644
--- a/packages/status-communities/src/messenger.ts
+++ b/packages/status-communities/src/messenger.ts
@@ -223,7 +223,6 @@ export class Messenger {
callback(messages.filter(isDefined));
}
};
- console.log(`querying ${chat.contentTopic} for ${startTime} to ${endTime}`);
const allMessages = await this.waku.store.queryHistory(
[chat.contentTopic],
{
@@ -231,10 +230,6 @@ export class Messenger {
callback: _callback,
}
);
- console.log(
- `ended querying ${chat.contentTopic} for ${startTime} to ${endTime}`
- );
-
return allMessages.length;
}