From 6be0710fda7a45a9bbe2e5c50cef47db3931e2ca Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Sun, 3 Mar 2024 14:32:11 -0800 Subject: [PATCH] Reposition AcceptOrDeny component --- .../FullConversation/AcceptOrDeny.tsx | 45 +++++++++++++++++ .../FullConversation/FullConversation.tsx | 50 +------------------ .../FullConversationController.tsx | 8 ++- 3 files changed, 50 insertions(+), 53 deletions(-) create mode 100644 src/component-library/components/FullConversation/AcceptOrDeny.tsx diff --git a/src/component-library/components/FullConversation/AcceptOrDeny.tsx b/src/component-library/components/FullConversation/AcceptOrDeny.tsx new file mode 100644 index 00000000..9aa3acc7 --- /dev/null +++ b/src/component-library/components/FullConversation/AcceptOrDeny.tsx @@ -0,0 +1,45 @@ +import { useTranslation } from "react-i18next"; +import { useState } from "react"; +import { useConsent } from "@xmtp/react-sdk"; +import { useXmtpStore } from "../../../store/xmtp"; + +export const AcceptOrDeny = ({ address }: { address: string }) => { + const { t } = useTranslation(); + const { allow, deny } = useConsent(); + const activeTab = useXmtpStore((s) => s.activeTab); + const changedConsentCount = useXmtpStore((s) => s.changedConsentCount); + const setChangedConsentCount = useXmtpStore((s) => s.setChangedConsentCount); + + const [modalOpen, setModalOpen] = useState(true); + + return activeTab === "requests" && modalOpen ? ( +
+

{t("consent.new_message_request")}

+

{t("consent.new_message_request_description")}

+
+ + +
+
+ ) : null; +}; diff --git a/src/component-library/components/FullConversation/FullConversation.tsx b/src/component-library/components/FullConversation/FullConversation.tsx index 3876988a..f0c9f746 100644 --- a/src/component-library/components/FullConversation/FullConversation.tsx +++ b/src/component-library/components/FullConversation/FullConversation.tsx @@ -1,14 +1,11 @@ import { useTranslation } from "react-i18next"; import type { VirtuosoHandle } from "react-virtuoso"; import { Virtuoso } from "react-virtuoso"; -import { useMemo, useRef, useState } from "react"; -import { useConsent } from "@xmtp/react-sdk"; -import { useXmtpStore } from "../../../store/xmtp"; +import { useMemo, useRef } from "react"; interface FullConversationProps { messages?: Array; isLoading?: boolean; - address: string; } const LoadingMessage: React.FC = () => { @@ -31,51 +28,9 @@ const BeginningMessage: React.FC = () => { ); }; -const AcceptOrDeny = ({ address }: { address: string }) => { - const { t } = useTranslation(); - const { allow, deny } = useConsent(); - const activeTab = useXmtpStore((s) => s.activeTab); - const changedConsentCount = useXmtpStore((s) => s.changedConsentCount); - const setChangedConsentCount = useXmtpStore((s) => s.setChangedConsentCount); - - const [modalOpen, setModalOpen] = useState(true); - - return activeTab === "requests" && modalOpen ? ( -
-

{t("consent.new_message_request")}

-

{t("consent.new_message_request_description")}

-
- - -
-
- ) : null; -}; - export const FullConversation = ({ messages = [], isLoading = false, - address, }: FullConversationProps) => { const virtuosoRef = useRef(null); const filteredMessages = useMemo(() => { @@ -87,9 +42,8 @@ export const FullConversation = ({ ), ...filtered, - , ]; - }, [isLoading, messages, address]); + }, [isLoading, messages]); return ( ) : null} - + + ); };